Regex pattern to remove any html code from a data

Hey, I am looking for a regex for validation so no HTML tags is entered into a data string.
for example: one of the validations I use for email is this

^((?!gmail.com|hotmail.com|yahoo.com|outlook.com|protonmail.com|onlinemailbox.cc|businessmailsystem.com|smcclient.com|emailsl.com|temporary-mail.net|companycontacts.net|yopmail.com|mail.ee|onlinemailbox.cc).)*$

I want something similar for not being able to enter a HTML tag

@Fahad_Sheji I am trying to find you best solution…give me little bit time

sure, thanks.

Have a Look at Seconds pattern

IT will lead to <[\s\S]+?>

@Fahad_Sheji
please use this one in assign activity.
System.Text.RegularExpressions.Regex.Replace(YourVariableString, “<[a-zA-Z/][^>]*>”, “ ”)

System.Text.RegularExpressions.Regex.Replace(YourVariableString, “<(.*?)>”, “ ”)

System.Text.RegularExpressions.Regex.Replace(YourVariableString, “(<([^>]+)>)”, “ ”)

Hey so basically I want to put this as a validation inside a form so no HTML code is entered, will it work still?

this is the dashboard where I put in the validation

and this is one of the validation for email we use
^((?!gmail.com|hotmail.com|yahoo.com|outlook.com|protonmail.com|onlinemailbox.cc|businessmailsystem.com|smcclient.com|emailsl.com|temporary-mail.net|companycontacts.net|yopmail.com|mail.ee|onlinemailbox.cc).)*$

@Fahad_Sheji First thing, regex is working correctly in almost every platform and I have tested these in Regex101 which is powerful tool regarding Regex. I am unable to understand about your form, please elaborate more about it

Okay, so I have a form and I want to add a regex validation so that no HTML tag is entered there when a user submits any information.
(i.e. sometime some user may add a <“b”> or <“i”> or different HTML tags like that when filling the form)

I want to add a validation in that field of the form that won’t allow them to enter any HTML tags

This is one of the validation regex we use for email addresses, want something similar to reject HTML tags in being entered

^((?!gmail.com|hotmail.com|yahoo.com|outlook.com|protonmail.com|onlinemailbox.cc|businessmailsystem.com|smcclient.com|emailsl.com|temporary-mail.net|companycontacts.net|yopmail.com|mail.ee|onlinemailbox.cc).)*$

This is the section in the form I enter the validation

@Fahad_Sheji No these regex are finding Tags in String and you want to validate. If you will put these in form it will accept tags as well.

Okay thanks for letting me know, could you help me with the regex to do the validation if possible, basically that is what I was looking for

@Fahad_Sheji Yeah I am trying but your requirment heading is different from actual one hehehe

Yeah my bad, I was a bit confused as well but when I finally figured out what I want, I already posted this question in the fourm.

Thanks for understanding and helping me out

@Fahad_Sheji is there any other option or you can just put regex

@Fahad_Sheji
Try this one.
It will not accept any string that constrains Html Tags
^(?!.<[^>]+>).

These are 4 Test cases and It accept only one

the one in the pic has a star at the end of regex and the regex you shared as text doesn’t, was that a mistake?
also where can I test a validation regex

btw I found this one online, will it work

</?[a-z][a-z0-9][^<>]>

^(?!.<[^>]+>).
image

I am unable to put star here I am pasted here but its not showing. pic is correct

@Fahad_Sheji I am testing your also


your one is not correct.

@Fahad_Sheji please test it and in case of any issue contact me and mark solution for others help