pattern for two characters next to each other

I'm using these 2 articles as reference.

What is the regex pattern for the less than symbol proceded with a forward slash </
the forward slash less proceded with the greater than symbol />

Basically I want to allow user to type everything into the text box except when those 2 cases occur.

But if > or < is by itself then that's OK.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Joe Winograd, Fellow&MVEDeveloperCommented:
The less-than, greater-than, and forward-slash symbols are all fine as literals and do no have to be escaped. So the needles are simply "</" and "/>".

Try this AutoHotkey code:

msgbox % foundpos ; should be 4 - needle found
Haystack:="abc< /def"
msgbox % foundpos ; should be 0 - needle not found
msgbox % foundpos ; should be 4 - needle found
Haystack:="abc/ >def"
msgbox % foundpos ; should be 0 - needle not found

Open in new window

Regards, Joe
maqskywalkerAuthor Commented:

I'm using ASP.NET web forms, C# and Javascript.

For the regex i'm using jquery.

For example, i'm using this regex pattern for Date Format.

            jQuery.validator.addMethod("DateFormat1", function (value, element) {
                // format mm/dd/yyyy
                return this.optional(element) || /\b\d{1,2}[\/]\d{1,2}[\/]\d{4}\b/.test(value);
            }, "Please enter a date in this format MM/DD/YYYY");

The regex pattern i'm using for Date Format MM/DD/YYYY is:

Joe Winograd, Fellow&MVEDeveloperCommented:
What does your last post have to do with the original question? You must have added the second article after you originally posted the question, because the only reference initially was to the AutoHotkey RegEx doc, which is why I responded. I'm not an expert in ASP.NET web forms, C#, or JavaScript. Truth be told, I'm not an expert in RegEx, either, but I know enough to answer your original question, especially within the context of AutoHotkey, as the AHK code that I posted shows. If you want more than what's in your initial question here, I suggest posting a new question. Regards, Joe
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Terry WoodsIT GuruCommented:
Note that a value like:
asdjfklsajdf 4/4/2018 aljdflasjdf

Open in new window

Would be valid for your date format pattern. If that matters, your pattern for that should probably be:
                return this.optional(element) || /^\d{1,2}[\/]\d{1,2}[\/]\d{4}$/.test(value);

Open in new window

Terry WoodsIT GuruCommented:
For the actual problem described in your question, I'm not sure whether the same structure of code will do what you need, but this pattern should detect the case you're describing:


Open in new window

Terry WoodsIT GuruCommented:
If you want the opposite of that pattern ie a pattern that only matches when both those cases are NOT found, then this should work:

Open in new window

Using [\s\S]* rather than .* will prevent the pattern failing on multiline input, in case you want to accept that.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
maqskywalkerAuthor Commented:
Thanks guys. Great examples.
Joe Winograd, Fellow&MVEDeveloperCommented:
You're welcome. Happy to help. Regards, Joe
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Regular Expressions

From novice to tech pro — start learning today.