Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hello,

I am new to regular expression. I need to extract between two string pattern ([[tag: & ]]) and for each occurrence.

For Example:

If the text is :

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus [[tag:4797897]] mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu.
[[tag:4797800]] [[tag:4797769]]

As I want the extract text between [[tag: and ]] , the desired output 4797897 , 4797800 and 4797769

I am using Javascript and JQuery

Can some please help me . Thanks in advance
Posted

1 solution

Try this:
/(?<=\[\[tag:)\d+(?=\]\])/g

on https://www.regex101.com/[^]
Read more: The 30 Minute Regex Tutorial[^]
 
Share this answer
 
v3
Comments
Mohibur Rashid 21-Jan-15 0:17am    
my favorite practice ground is
http://www.regexr.com/

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900