user1705636
user1705636

Reputation: 233

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

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?

Upvotes: 3

Views: 315

Answers (1)

Anirudha
Anirudha

Reputation: 32827

Use this regex to split

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

check it out here

Upvotes: 2

Related Questions