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 extract out the variable of special content format?

How to extract out the variable of special content format?

I have below data:

# == 2.This is a ==
111111
222222
# == 2.This is a ==

# == 3.This is b ==
333333
# == 3.This is b ==

4
5

# == 2.This is a ==
66
77
8
# == 2.This is a ==

# == 4.This is c ==
9

# == 5.This is d ==
11
12
13
# == 5.This is d ==

10
# == 4.This is c ==

you see the special format # == {variable} ==
I want to extract out the variables.

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

but I don’t know how to do with this, I have searched SO,
but neither is suitable for this situation.

and before asking this question I have tried:

var pattern = /# == ([a-zA-Z0-9.\s]+) ==/g 

var matchArr=content.match(pattern)

but I want to extract out the ([a-zA-Z0-9.\s]+) not /# == ([a-zA-Z0-9.\s]+) ==.

>Solution :

I’m not sure how to implement the solution in Javascript, but you can try something like this regex:

# == ([0-9.\sa-zA-Z]+)

See the solution in action here:
https://regex101.com/r/OCLO1k/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