Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'd like to get the single strings of a pipe-separated string, with "pipe escaping" support, e.g.:

fielda|field b |field|with|pipe|inside

would get me:

array("fielda", "field b ", "field|with|pipe|inside")

How would I reach that goal with a regular expression?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
625 views
Welcome To Ask or Share your Answers For Others

1 Answer

Split  by this (?<!\)|

See demo.The lookbehind makes sure | is not after .

https://regex101.com/r/pM9yO9/15


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...