I have a string something like this
var test = 'Hello you have multiple L2:Me here;L3:Me not here; and some other text...';
I want to get string array
L2:Me here
L3:Me not here
The format is L(some number):text;
What will be regex?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If those semicolons are always going to be there, you can use something like this:
Explanation:
L[0-9]+:matches L followed by any sequence of numbers, followed by a colon (i.e."L105:")[^;]+matches any character that’s not a semicolon (the[^;]part) at least once (the+part), and only stops once it reaches a semicolongflag makes the matches global, that is, to not just find the first match and stop