Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: JAVA [[a-z]&&[^aeiou]] equivalence

by vincentaxhe (Beadle)
on Jul 10, 2024 at 06:48 UTC ( [id://11160501]=note: print w/replies, xml ) Need Help??


in reply to Re: JAVA [[a-z]&&[^aeiou]] equivalence
in thread JAVA [[a-z]&&[^aeiou]] equivalence

it's a good approach,seems informal, I wonder is there a better way.
  • Comment on Re^2: JAVA [[a-z]&&[^aeiou]] equivalence

Replies are listed 'Best First'.
Re^3: JAVA [[a-z]&&[^aeiou]] equivalence
by hippo (Archbishop) on Jul 10, 2024 at 12:55 UTC

    Perl is intentionally informal. This is one of its greatest strengths.


    🦛

      Regexes are a DSL available as sub language in many languages, and I'm confident most allow using lookahead assertions for and-combining regexes. Even in Java.

      So it's not an exclusive Perl thing.

      See this JS doc for instance:

      Lookahead_assertion#pattern_subtraction_and_intersection¹

      It's also worth discussing the pro and cons of the regex-sets solution posted by choroba.

      The lookaheads are generic and not restricted to character classes and allow combining any kind of patterns.

      But in the case of handling character classes only, I expect the regex-class solution to be faster and better readable.

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

      ¹) Using lookahead, you can match a string multiple times with different patterns, which allows you to express complex relationships like subtraction (is X but not Y) and intersection (is both X and Y).

    A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-09-15 07:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The PerlMonks site front end has:





    Results (21 votes). Check out past polls.

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.