javascript - Regex - any one or more character followed by one new line and equal sign -


i'm making open-source markdown parser.

i have bit of problem on regex i'm not expert on regex.

r = r.replace(/(.*)(\n=$)/g, '<h1>$1</h1>'); 

what want here 1 or more character follow \n new line , next line 1 or more of = only.

input is:

hello world\n===

expected output:

hello world

the 1 have worked when have 2 new lines strip off equal signs too.

so if have this

hello world\n\n===

i should see this

hello world  === 

you've got end anchor ($) means match of there no other characters following first equals. furthermore, looks want able match 1 or more equals signs.

i think want:

"hello world\n===".replace(/(.+)\n=+/g, '<h1>$1</h1>'); // <h1>hello world</h1> 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -