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.
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.
Share Improve this question asked Jul 25, 2015 at 11:11 user2565496user2565496 251 gold badge1 silver badge6 bronze badges2 Answers
Reset to default 2You can use:
/\bws=([^;]*)/
and grab captured group #1
RegEx Demo
([^;]*)
will match 0 or more of any character that is not ;
I would use this:
ws=(.*?)(;|$)
Try it online: http://regexr./3bfbv
ws=
searches for that exact text(
starts the matching group.*?
searches for any characters, but as few characters as possbile ("non-greedy"))
stops the matching group(;|$)
searches for either a;
or the end of the text (or the line)