Regex expert needed.

User 132002 Photo


Registered User
131 posts

I have been searching the internet for hours now, but couldn't find a solution.
Obviously I haven't searched with the correct words.

In my Regex field I have to disallow certain words.
Let's say I don't want the visitor to type my name: Soren.

How would I do this?

Søren
Søren, Denmark
User 187934 Photo


Senior Advisor
20,271 posts

I would think a drop down with the actual words allowed would be the way to go.:)
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 132002 Photo


Registered User
131 posts

Hello Eric

I don't think this would be the solution.
It could be a long text field with many words, but some of them would be disallowed.

Thanks for answering me.
Søren, Denmark
User 187934 Photo


Senior Advisor
20,271 posts

Can I ask why your trying to eliminate certain text entry?:)
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 132002 Photo


Registered User
131 posts

Certainly.

It is for a Fishing Association and some types of fish is not allowed.

Let's say the word Salmon is not allowed in the field, they should get an error message if typing the word Salmon.
Søren, Denmark
User 187934 Photo


Senior Advisor
20,271 posts

I would think the best way to handle this is to create a list for them to choose from. With the new conditionals you'll be able to categorize your fish lists. What happens if they misspell a fish or enter one that nobody knows exist?
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 132002 Photo


Registered User
131 posts

Finally found the solution.

Maybe it could be some help to other with this problem.

Select custom regex input, insert this into the regex field.

/^((?!word|word|word|word|word).)*$/

Replace word with the word you want to avoid being typed in the field.

Now if someone type the word they will get an error message.
Søren, Denmark
User 187934 Photo


Senior Advisor
20,271 posts

Thanks for posting that.:) I'm still curious how your going to handle misspellings.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 132002 Photo


Registered User
131 posts

Misspelling could be a problem.
I don't know how many names we have for a fish in Denmark.
In a drop down box I have the names for the fish that it is usually to catch.
I also have the possibility to select other.
If other is selected the visitor must type the name for the fish.

The Fishing Association I'm trying to help don't want to receive any information if the visitor want to tell them about catching a Brown trout. If they try to type Brown trout they are told it is not legal to type this.
This is where it could be misspelled. I'm avoiding this with the use of a *.
Now the regex field look like this: /^((?!Bro*|bro*).)*$/

This works for Denmark, of course it could be different in other countries.
Søren, Denmark
User 56337 Photo


Registered User
12 posts

Try /bsorenb/

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.