Wednesday, June 5, 2024
 Popular · Latest · Hot · Upcoming
99
rated 0 times [  101] [ 2]  / answers: 1 / hits: 13996  / 9 Years ago, sat, july 25, 2015, 12:00:00

I have 2 kinds of data.



One data is something like this



ws=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9


and the another data like this



ws=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9;utmz=111872281.1437151704.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none);


I wanna get the ws value, like



eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9


But i got problems for split the ; character. Because sometime the data have the character, but sometimes it doesn't have that character.



I already tried using



ws=([^]*);?


and



ws=([^]*)[;?]


and I still doesn't get the correct data.
Thank you very much.


More From » regex

 Answers
23

You can use:



/bws=([^;]*)/


and grab captured group #1



RegEx Demo



([^;]*) will match 0 or more of any character that is not ;


[#35360] Friday, July 24, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
davion

Total Points: 458
Total Questions: 109
Total Answers: 100

Location: Taiwan
Member since Mon, Sep 6, 2021
3 Years ago
;