Match a string that does not contain a specific sequence of characters
I am trying to use regular expressions to match a string that does not contain a sequence of characters less than a character (<) followed by a space. Here are some examples
Valid - "A new description."
Valid - "A < new description."
Invalid -"A <new description."
I can't seem to find the correct expression to get the match. I am using the Microsoft regex validator, so I need it to be a match, not use code to deny the match.
Any help would be appreciated.
Thanks,
Dale
@"^(?:[^<]+|<(?!\s))*$"
Doing a negative lookahead for space allows it to match if the last character on the line is "<". Here's another way:
^(?!.*<\S).+$
Looker scans the entire line for "<" followed by a character without spaces. If not found, ". +" Goes ahead and matches the string.
source to share
I think this might be what you are looking for.
Valid - "A new description."
Valid - "A < new description."
Invalid - "A <new description."
Try this: <\S
This looks for something with less than a character and no space after it.
In this case, it will match "<n"
Not sure how much you want it to match.
source to share