Answer the question
In order to leave comments, you need to log in
How to exclude links from text using regex?
You need to use one regular expression using javascript to find all the words in the text, but skip what is in square brackets and skip links. The words will be used for spell checking. Only one regular expression can be used.
Test text:
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua. Ut enim ad minim veniam, quis nostrud exercitation
ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit
esse cillum dolore eu :fugiat: nulla pariatur. Excepteur sint
occaecat :cupidatat [non] proident:, sunt in culpa qui officia
deserunt mollit anim id est laborum.
abcdefghijklmnopqrstuvwxyz [ABCDEFGHIJKLMNO] PQRSTUVWXYZ
0123456789 _+-.,[email protected]#$%^&*();\/|<>"'
12345 -98.7 3.141 .6180 9,000 +42
555.123.4567 +1-(800)-555-2468
[email protected] <[email protected]>
www.demo.com {http://foo.co.uk/ }
[https://marketplace.visualstudio.com/ite] ms?itemName=chrmarti.regex
https://github.com/chrmarti/vscode-regex asdfasdf
/\b[^\s]+\b/g
/[^\[]*\]/g
/(\b[^\s]+\b)(?!([^\[]*\]))/g
/\b(http)[^\s]+\b/g
/(\b[^\s]+\b)(?!([^\[]*\]))(?!(\bhttp[^\s]+\b))/g
Answer the question
In order to leave comments, you need to log in
/(\b[^\s]+\b)(?!([^\[]*\]))/g
If I understand correctly, the second group filters the first
(?!([^\[]*\]))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question