Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to find '|' pattern in string in java?

Tags:

java

regex

I want to split string.

for example)

str1=str\|2|str3=str4

result)

str1=str\|2
str3=str4

how to split it using pattern in java?

like image 734
user1705636 Avatar asked Jul 17 '26 04:07

user1705636


1 Answers

Use this regex to split

(?<=\\|\\d)\\|
            --
             |
             |->kept | out so it doesnt get included in the result!

check it out here

like image 62
Anirudha Avatar answered Jul 18 '26 19:07

Anirudha



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!