I'm using this regular expression:
var regex = /\<.*?.\>/g
to match with this string:
var str = 'This <is> a string to <use> to test the <regular> expression'
using a simple match:
str.match(regex)
and, as expected, I get:
["<is>", "<use>", "<regular>"]
(But without the backslashes, sorry for any potential confusion)
How can I get the reverse result? i.e. what regular expression do I need that does not return those items contained between <
and >
?
I tried /(^\<.*?\>)/g
and various other similar combos including square brackets and stuff. I've got loads of cool results, just nothing that is quite what I want.
Where I'm going with this: Basically I want to search and replace occurences of substrings but I want to exclude some of the search space, probably using < and >. I don't really want a destructive method as I don't want to break apart strings, change them, and worry about reconstructing them.
Of course I could do this 'manually' by searching through the string but I figured regular expressions should be able to handle this rather well. Alas, my knowledge is not where it needs to be!!