Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: Looking for a cleaner regex ( trie since 5.10 ! )

by LanX (Saint)
on Dec 08, 2017 at 14:45 UTC ( [id://1205174]=note: print w/replies, xml ) Need Help??


in reply to Re: Looking for a cleaner regex
in thread Looking for a cleaner regex

> See Regexp::Optimizer

The author should add a prominent remark that Perl is supporting trie optimization for over 10 years already. ..

perl5100delta#Trie-optimisation-of-literal-string-alternations

So what's the benefit of this module with current Perl, unless you generate a regex for another language?

update: see also Re^3: Looking for a cleaner regex (trie) ff

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Wikisyntax for the Monastery

  • Comment on Re^2: Looking for a cleaner regex ( trie since 5.10 ! )

Replies are listed 'Best First'.
Re^3: Looking for a cleaner regex ( trie since 5.10 ! )
by Anonymous Monk on Dec 08, 2017 at 15:12 UTC
    making the regex shorter and easier to read?
      Do you really find /foo(?:[bx]ar|zap)/ easier to read than /foobar|fooxar|foozap/? (Example copied from the documentation).

      Or,

      /(?^:(?^x:(?:s(?:e(?:t(?:(?:(?:(?:hos|ne)t|gr)en|s(?:erven|ockop))t|p( +?:r(?:iority|otoent)|went|grp))|m(?:ctl|get|op)|ek(?:dir)?|lect|nd)|y +(?:s(?:write|call|open|read|seek|tem)|mlink)|h(?:m(?:write|read|ctl|g +et)|utdown)|ocket(?:pair)?|(?:qr|ta)t|printf|ubstr|leep|rand|in)|g(?: +e(?:t(?:p(?:r(?:oto(?:byn(?:umber|ame)|ent)|iority)|w(?:ent|nam|uid)| +eername|grp|pid)|s(?:erv(?:by(?:name|port)|ent)|ock(?:name|opt))|host +(?:by(?:addr|name)|ent)|net(?:by(?:addr|name)|ent)|gr(?:ent|gid|nam)| +login|c))?|mtime|lob|t)|r(?:e(?:ad(?:lin[ek]|pipe|dir)?|(?:quir|vers| +nam)e|winddir|set|cv|f)|index|mdir|and)|c(?:h(?:r(?:oot)?|dir|mod|own +)|o(?:n(?:tinue|nect)|s)|lose(?:dir)?|aller|rypt|mp)|l(?:o(?:c(?:alti +me|k)|g)|i(?:sten|nk)|c(?:first)?|e(?:ngth)?|(?:sta)?t)|e(?:nd(?:(?:h +os|ne)t|p(?:roto|w)|serv|gr)ent|x(?:ec|it|p)|of|q)|u(?:(?:n(?:lin|pac +)|mas)k|c(?:first)?|time)|f(?:or(?:mline|k)|c(?:ntl)?|ileno|lock)|w(? +:a(?:it(?:pid)?|ntarray|rn)|rite)|m(?:sg(?:ctl|get|rcv|snd)|kdir)|t(? +:ell(?:dir)?|runcate|imes?)|d(?:bm(?:close|open)|ump|ie)|a(?:ccept|la +rm|tan2|bs|nd)|__(?:(?:FIL|LIN)E|SUB)__|o(?:pen(?:dir)?|rd?|ct)|b(?:i +n(?:mode|d)|less)|i(?:n(?:dex|t)|octl)|v(?:alues|ec)|p(?:ack|ipe)|n(? +:ot|e)|quotemeta|x(?:or)?|CORE|join|kill|hex)))/

      versus

      /CORE|__FILE__|__LINE__|__SUB__|abs|accept|alarm|and|atan2|bind|binmod +e| bless|caller|chdir|chmod|chown|chr|chroot|close|closedir|cmp|connect| continue|cos|crypt|dbmclose|dbmopen|die|dump|endgrent|endhostent|endne +tent| endprotoent|endpwent|endservent|eof|eq|exec|exit|exp|fc|fcntl|fileno|f +lock| fork|formline|ge|getc|getgrent|getgrgid|getgrnam|gethostbyaddr| gethostbyname|gethostent|getlogin|getnetbyaddr|getnetbyname|getnetent| getpeername|getpgrp|getppid|getpriority|getprotobyname|getprotobynumbe +r| getprotoent|getpwent|getpwnam|getpwuid|getservbyname|getservbyport| getservent|getsockname|getsockopt|glob|gmtime|gt|hex|index|int|ioctl|j +oin| kill|lc|lcfirst|le|length|link|listen|localtime|lock|log|lstat|lt|mkdi +r| msgctl|msgget|msgrcv|msgsnd|ne|not|oct|open|opendir|or|ord|pack|pipe| quotemeta|rand|read|readdir|readline|readlink|readpipe|recv|ref|rename +| require|reset|reverse|rewinddir|rindex|rmdir|seek|seekdir|select|semct +l| semget|semop|send|setgrent|sethostent|setnetent|setpgrp|setpriority| setprotoent|setpwent|setservent|setsockopt|shmctl|shmget|shmread|shmwr +ite| shutdown|sin|sleep|socket|socketpair|sprintf|sqrt|srand|stat|substr| symlink|syscall|sysopen|sysread|sysseek|system|syswrite|tell|telldir|t +ime| times|truncate|uc|ucfirst|umask|unlink|unpack|utime|values|vec|wait| waitpid|wantarray|warn|write|x|xor/x

      ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
Re^3: Looking for a cleaner regex ( trie since 5.10 ! )
by Anonymous Monk on Dec 09, 2017 at 10:46 UTC
    It isnt limited by trie max limit maybe?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1205174]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-24 02:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found