Essentially I am having problems with creating a regex for a list such as :
1. Eccentric Shop Teacher 20M+ Good EST
2. Wanwood Crown 18M+ Low WWC
3. Domino Crown 16M+ Great DC
4. Dominus Empyreus 16M+ Great Emp
The regex I am using : (\\d+.\\s)([\\w\\'\\s\\d])([\\d\\w\\+])
Which only matches :
But I want it to match it like :
Could any experts with regex help me?
Try this regex:
var regex = /(\d+\.)\s+([a-z]+(?:\s[a-z]+)*)\s+(\d+M\+)\s+([a-z]+)\s+([a-z]+)/i;
Explanations:
(\d+\.) # first capturing group: one or more digits and a dot
\s+ # spaces
( # open the second capturing group
[a-z]+ # one or more letters (a word)
(?: # open a non capturing group
\s[a-z]+ # a space followed by a word
)* # close the non capturing group, repeat zero or more times
) # close the second capturing group
\s+ # one or more spaces
(\d+M\+) # third capturing group: one or more digits, M, +
\s+
([a-z]+) # fourth capturing group: a word
\s+
([a-z]+) # fifth capturing group: a word
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.