Search code examples
phpregexpcre

Shorten regex any character including whitespace, alphanum, special char, and unicode


I want to match any character after some word (limit is an example).

✔ nnn : am
-limitaaaa
ça UNICODE HERE
sdasdsadaw
✔ UNICODE HERE
limitaaaa,.@#!~`%$&*()[]{}|\+=-_?/'":;.><,
777723xx sss fff s :,

my current regex. https://regex101.com/r/bSbUBG/2

/limit+([.*\s\w\d\p{M}\p{L}\p{S},:@#!~`%$&()\[\]\{\}\|\\+=\-_\?\/\'";><]+)/

My regex works, but it looks too long. My question is can I make it shorter?

Note: If you need to know what kind of language that I used, I using PHP for this.


Solution

  • You could either use

    limit([\s\S]+)
    

    Or

    limit(.+)
    

    in DOTALL mode (s flag).

    See a demo on regex101.com or this one for the latter.