Link to home
Start Free TrialLog in
Avatar of maqskywalker
maqskywalker

asked on

working with regular expressions and jquery

I have this example fiddle:
https://jsfiddle.net/h6vkt3jg/2/

In this example I'm using this regex pattern:

/<\/|\/>/

With this pattern only when you type </ together or /> together does validation pass and the button becomes enabled.

When you run it, it looks like this. The button is disabled.
 
User generated image
So if you type the symbols separately that doesn’t pass.

User generated image


If I type the </ symbols together regardless whether there is text before or after it, validation passes.
 
User generated image
If I type the /> symbols together regardless whether there is text before or after it, validation passes.


User generated image

How do I revised my regex example to do the opposite?
I want to add Not to this regex pattern /<\/|\/>/

So in my example the validation should pass for everything except </ or this />

The tooltip should only popup if I type </ or this />
SOLUTION
Avatar of David S.
David S.
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of maqskywalker
maqskywalker

ASKER

thanks. great examples.