I want a regex pattern to find all the words of this format [xyzblab23la].
For example if the text has something like the following,
Lorem 开发者_StackOverflow社区Ipsum dolor[32a] ameit[34]
I should be able to find the [32a] and [34]. Please tell me what is the regex for this pattern?
You can use the following regex globally to find all the matches:
\[.*?\]
or
\[[^\]]*\]
Explanation:
\[:[is a meta char for the start of the char class, so to match a literal[we need to escape it..*?: match everything in a non-greedy way.\]: to match a literal][^\]]: a char class that matches any char other than][^\]]*: zero or more char of the above type.
Try this regular expression:
\[[^[\]]+]
A short explanation:
\[matches a plain[[^[\]]+matches one or more arbitrary characters except[and]]matches a plain]
/(\[[a-z0-9]+\])/i/
加载中,请稍侯......
精彩评论