Regex support

Seh

New member
I struggle for regex text to match this
Ultra HD or enabled
I write (Ultra HD)|(enabled) but it matches Ultra enabled which is wrong. Please help
 

Dimlos

Well-known member
I don't know how you are using it, could you please upload a screenshot?

Ultra HD|enabled

I don't think it's a problem.
 

RSF

Well-known member
"Ultra enabled" matches the regular expression (Ultra HD)|(enabled), since the regex is looking for the word "enabled" anywhere in the string, and "Ultra enabled" does contain "enabled"...

If you want to match only the exact phrase "Ultra HD" or the exact phrase "enabled" (all by themselves, in both cases), the regex needs to be ^((Ultra HD)|(enabled))$
(The ^ and $ indicate to match the beginning and end of a string)

If you want to match something differently, please upload an example screenshot as @Dimlos mentions.
 

paps93fr

New member
If you are looking for a sentence containing both "Ultra HD" and "enabled" you need a regex searching for both keywords not only one or another. Something like (Ultra HD.+enabled|enabled.+Ultra HD) if enabled keyword can be in front or behind Ultra HD, or just (Ultra HD.+enabled) if enabled can only be behind.

You could try it on https://regex101.com/
 

FrameXX

Well-known member
Sorry @FrameXX but in your example "Ultra enabled" matches too...

As I'm not a Regex specialist I tried your suggestion because I love learning but unfortunately it seems that it's not the right way to achieve what Seh wants to.

You are right. I edited my pattern.
 

MacroDroidDev

Administrator
Staff member
It's worth investigating ChatGPT as that should be good at generating regex values when given a good description.
 
Top