143
Views
14
Comments
regex_search returning false even with matching text
Question

I am using regex_search function to validate text in my reactive web application but it is returning false everytime. I want to validate that the text must have atleast one small letter, one capital letter, one number and one special character. The length of the text should be between 6-12, below is my regex pattern for this :

SyntaxEditor Code Snippet

^((?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[!@#$%^&*()_+?<>[\]{}=-])).{6,12}

Outsystem version: 11.7.9

2026-02-26 06-29-24
Rahul
 
MVP

Hi Nitin,

I have checked your pattern and its working

Find attached oml and use Sample Link For Regex


Regards

Rahul Sahu

Datetime.oml
2026-01-19 17-09-56
Carlos Lessa
 
MVP

Nitin Soni wrote:

I am using regex_search function to validate text in my reactive web application but it is returning false everytime. I want to validate that the text must have atleast one small letter, one capital letter, one number and one special character. The length of the text should be between 6-12, below is my regex pattern for this :

SyntaxEditor Code Snippet

^((?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[!@#$%^&*()_+?<>[\]{}=-])).{6,12}

Outsystem version: 11.7.9

Try this one:

^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^\da-zA-Z]).{6,12}$

you can test on this site or in your logic:https://regexr.com/


Best Regards

Carlos Lessa


UserImage.jpg
Nitin Soni

Carlos Lessa wrote:

Nitin Soni wrote:

I am using regex_search function to validate text in my reactive web application but it is returning false everytime. I want to validate that the text must have atleast one small letter, one capital letter, one number and one special character. The length of the text should be between 6-12, below is my regex pattern for this :

SyntaxEditor Code Snippet

^((?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[!@#$%^&*()_+?<>[\]{}=-])).{6,12}

Outsystem version: 11.7.9

Try this one:

^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^\da-zA-Z]).{6,12}$

you can test on this site or in your logic:https://regexr.com/


Best Regards

Carlos Lessa


It is returning true for test@123, this string does not have capital letter

I should return false


2026-01-19 17-09-56
Carlos Lessa
 
MVP

Nitin Soni wrote:

Carlos Lessa wrote:

Nitin Soni wrote:

I am using regex_search function to validate text in my reactive web application but it is returning false everytime. I want to validate that the text must have atleast one small letter, one capital letter, one number and one special character. The length of the text should be between 6-12, below is my regex pattern for this :

SyntaxEditor Code Snippet

^((?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[!@#$%^&*()_+?<>[\]{}=-])).{6,12}

Outsystem version: 11.7.9

Try this one:

^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^\da-zA-Z]).{6,12}$

you can test on this site or in your logic:https://regexr.com/


Best Regards

Carlos Lessa


It is returning true for test@123, this string does not have capital letter

I should return false


funny on that website it works, I will try the same pattern in OS and check


2026-01-19 17-09-56
Carlos Lessa
 
MVP

Nitin Soni wrote:

I am using regex_search function to validate text in my reactive web application but it is returning false everytime. I want to validate that the text must have atleast one small letter, one capital letter, one number and one special character. The length of the text should be between 6-12, below is my regex pattern for this :

SyntaxEditor Code Snippet

^((?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[!@#$%^&*()_+?<>[\]{}=-])).{6,12}

Outsystem version: 11.7.9

I tried your pattern in the site I quote above and if you remove the first and last brackets and add a $ sign in the end, your pattern will start to work there, check your pattern with this additions

^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[!@#$%^&*()_+?<>[\]{}=-]).{6,12}$

Best regards

Carlos Lessa


2026-02-26 06-29-24
Rahul
 
MVP

Hi  Nitin,


Find updated oml.

hope it will help you.


Regards

Rahul Sahu

RegexPatten.oml
UserImage.jpg
Nitin Soni

The regex pattern is working, the issue was in IgnoreCase property. IgnoreCase property was set to true.

I have set it to false and it is working now

Thanks

2026-01-19 17-09-56
Carlos Lessa
 
MVP

Nitin Soni wrote:

The regex pattern is working, the issue was in IgnoreCase property. IgnoreCase property was set to true.

I have set it to false and it is working now

Thanks

True, I didn't remember to tell you to check that, good luck with that

ps:. Follow the advice of Justin and Kilian

best regards

Carlos Lessa


2019-03-24 20-44-19
Hugo Dias

Carlos Lessa wrote:

Nitin Soni wrote:

The regex pattern is working, the issue was in IgnoreCase property. IgnoreCase property was set to true.

I have set it to false and it is working now

Thanks

True, I didn't remember to tell you to check that, good luck with that

ps:. Follow the advice of Justin and Kilian

best regards

Carlos Lessa


Hi,


If you are using the regex to validate a password it will check with sucess the following case:

      test_@123 ae 

Can you have a space in the middle of the Text var?


Always try to work around without the use of regular expressions.


Best Regards.


2026-01-19 17-09-56
Carlos Lessa
 
MVP

Hugo Dias wrote:


Hi,


If you are using the regex to validate a password it will check with sucess the following case:

      test_@123 ae 




Hi Hugo, I'm not sure if you replied my post cuz I said to Trust the advice of 2 MVPs with years of experience but I think that I didn't say that your opinion isn't valid or right. I any case Wasnt the impression I tried to pass but the one to trust the 2 MVPs

But coming back to the regex code, the one in the post will accept the blank space but the right  regex can validate if you have space on your string, check this pic bellow I use your example with a different regex code

and without space will pass

Regex can do a lot of validation if you use the right one.

Best regards

Carlos Lessa

2019-03-24 20-44-19
Hugo Dias

Carlos Lessa wrote:

Hugo Dias wrote:


Hi,


If you are using the regex to validate a password it will check with sucess the following case:

      test_@123 ae 




Hi Hugo, I'm not sure if you replied my post cuz I said to Trust the advice of 2 MVPs with years of experience but I think that I didn't say that your opinion isn't valid or right. I any case Wasnt the impression I tried to pass but the one to trust the 2 MVPs

But coming back to the regex code, the one in the post will accept the blank space but the right  regex can validate if you have space on your string, check this pic bellow I use your example with a different regex code

and without space will pass

Regex can do a lot of validation if you use the right one.

Best regards

Carlos Lessa

Hi Carlos,

First of all, I was just focused on the problem and I was trying to add value to this subject. Nothing personal.
I was just wondering if it is the case to validate a password it would probably not work as intended.

Best Regards.

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Note that a single RegEx is not really the best way to go here. Regular expressions can find a certain sequence very well, but testing for three occurences in random order in a string isn't really possible unless you use a pattern with all permutations (which quickly gets very unwieldly). Also, testing for the length is better done with Length().

2019-11-12 17-31-26
Justin James
 
MVP

Kilian Hekhuis wrote:

Note that a single RegEx is not really the best way to go here. Regular expressions can find a certain sequence very well, but testing for three occurences in random order in a string isn't really possible unless you use a pattern with all permutations (which quickly gets very unwieldly). Also, testing for the length is better done with Length().

Agree 100% with Kilian. It also makes it much easier to debug, add more rules as-needed, and so on.

J.Ja

2019-03-24 20-44-19
Hugo Dias

Hi,


Like some already said you should avoid using regular expressions on your logic because they usually are difficult to maintain in the future. So take that into consideration if you chose to use them.


Anyway, for your problem I would suggest that first of all you use the Trim() on your Text Var and then check the length with the function Length().


Then you can use this regex pattern:

^(?=.*[\d])(?=.*[a-z])(?=.*[A-Z])(?=.*([^\w\s]|[_]))(\S+)$


Here are the results on regex101: https://regex101.com/r/okJibV/2


Finally, this is an example how you could implement the action in OutSystems


Cheers.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.