How can I get the string before the character "|" using regular expressions?
For example, I have "data1|data2" and I want to return "data1".
How can I get the string before the character "|" using regular expressions?
For example, I have "data1|data2" and I want to return "data1".
You want this regex: ^.+?(?=\|)
^
beginning of line.+?
one or more characters, as few as possible(?=)
forward look ahead assertion; make sure you can see the enclosed pattern\|
a literal |
character