http://qs321.pair.com?node_id=1230801


in reply to Looking for a Regex

if( m[ ^'?[a-z] ## start with letter or an apost +rophy followed by one [a-z0-9'-_]+ ## Alphanumeric + '-_ (?[a-z0-9] | s') $ ## ends with alphanumeric or ]x and not m[''|--] }{ ## Ok! }

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
In the absence of evidence, opinion is indistinguishable from prejudice. Suck that fhit

Replies are listed 'Best First'.
Re^2: Looking for a Regex
by 1nickt (Canon) on Mar 03, 2019 at 23:56 UTC

    Nice! At first I thought what a shame it was that you would provide code-writing service for someone who showed no effort, but then I realised you were really providing code that does not compile, so as to force the OP to show effort. Sneaky!


    The way forward always starts with a minimal test.
      ... so as to force the OP to show effort.

      And if you'd kept that to yourself, we might have found out if the OP had tried it.

      With following the error messages and just a little effort, what I posted can become:

      #! perl -slw use strict; for( qw[ ab123 'ab123s 'ab123's ] ) { if( m[ ^'? [a-z] ## start with letter or an apostro +phy followed by one [a-z0-9'-_]+ ## Alphanumeric + '-_ (?: [a-z0-9] | s') $ ## ends with alphanumeric or s' ]x and not m[''|--] ## No doubled ''s or --s ){ print "$_: Ok!"; } else { print "$_: Bad!"; } } __END__ C:\test>junk ab123: Ok! 'ab123s: Ok! 'ab123's: Ok!

      Which gives a starting point but not the whole thing.

      If you're going to bother saying something, best make it something useful.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
      In the absence of evidence, opinion is indistinguishable from prejudice. Suck that fhit

        LOL you are so Trumpian with the truth sometimes. You now claim that you *deliberately* posted broken code? Ha-ha.

        "If you're going to bother saying something, best make it something useful."

        Oh, but I did. It was useful in pointing out that you offered a complete solution to a question that showed no effort, but also posted non-compiling code (although that didn't stop the sheep upvoting blindly as they always do); as well as in pointing out your utter lack of humility and ability to admit a mistake.


        The way forward always starts with a minimal test.