Skip to content
Advertisement

Javascript extract strings that match regex from text

I’m trying to get a set of strings from a paragraph that match the format of 4chan’s quotes: >>1111111 where it starts with >> followed by 7 digits.

JavaScript

Both >>1111000 and >>1111001 would be extracted from the text above which I would then split into the digits after.

Advertisement

Answer

You can use the following which will match lines starting with 2 > characters followed by 7 digits:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement