Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to find specific character with x times repeated, and after that character capture everything?

Have statement like [[+pagetitle]] and [[++site_name]], needed separate and find each individually.

I expecting to get [[+pagetitle]] and [[++site_name]] separately with 2 different of course regexp.

Tried:
\[{2}\+{1}.*?\]{2}
\[{2}\+{1}.+\]{2}

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

What i currently achieved, is collecting everything. \[{2}\+{1}.*?\]{2} with capture same as + and ++ as the same, but they have different ideas behind, how to find each separate? Regex101 page https://regex101.com/r/uezzxc/1

I expecting to get [[+pagetitle]] and [[++site_name]] separately with 2 different of course regexp

>Solution :

Using \[{2}\+[^+]*?\]{2} you can match [[+pagetitle]] and not [[++site_name]] because [^+] matches anything but a + sign.

To match [[++site_name]] and not [[+pagetitle]] you could use \[{2}\+{2}.*?\]{2}.

https://regex101.com/r/acgtj6/1

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading