i have a text like this apple man <span field="apply to|1232sdsdf_nsdnfnln|Data" contenteditable="false"> open the door <span field="apply to|1232sds$df_nsdnfnln|Data"
. i wrote a regex like this to get the items separated by |
. but it takes only words. If there is characters like @$%
.
This is the regex i'm using <span\\s+field="([\\w\\s]+)\\|(\\w+)\\|(\\w+)
Instead of specifying \\w+
, which only captures numbers, letters and the underscore , you could specify any amount of characters that aren't the character that ends the group by using a ^
, followed by the characters that won't match, within a []
:
<span\s+field="([^|]+)\|([^|]+)\|([^"]+)
So [^|]+
will match any at least one character that isn't |
, and [^"]+
will match at least one character that isn't "
.
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.