Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Hi , dear monks

I'm using expect to detect login sequences, and I'm facing this un-explicable behaviour of my regex

This is the regex
(([#%:>~\$\] ])(?!\2)){3,4}|([\w\-\.]*)\$ *$|(\w[@\/]\w|sftp).*?[#%>~\ +$\]]|^[#%\$>\:]~] *$

And the text it fails against is shown below.

This regex runs correctly in Perl 5.30

And it fails in Perl 5.34

It works as expected in testing websites as : https://regex101.com/

I expected to match this sequence --> : ~#

But instead is matching --> \s\s#

as seen in the "Match string message below"

Match string: ` #'


I would like to confirm with your wisdom before opening bug request.
###################################################################### +######## # This system is a restricted access system. + # # If collected security information reveals possible criminal activity + that # # exceeds privileges, evidence of such activity may be provided to the + rele- # # vant authorities for further action. By continuing past this point, +you # # expressly consent to this security monitoring. + # ###################################################################### +######## hostname: ~# spawn id(5): Does `################################################### +###########################\r\n# This system is a restricted access s +ystem. #\r\n# If collected security i +nformation reveals possible criminal activity that #\r\n# exceeds pr +ivileges, evidence of such activity may be provided to the rele- #\r\ +n# vant authorities for further action. By continuing past this point +, you #\r\n# expressly consent to this security monitoring. + #\r\n########################################## +####################################\r\n\r\nhostname: ~# ' match: pattern #2: -eof `'? No. pattern #3: -re `\\[__PAC__SUDO__PROMPT__\\]'? No. pattern #4: -re `^.+ontinue connecting \\(([^/]+)\\/([^/]+)(?:[^)]+) +?\\)\\?\\s*$'? No. pattern #5: -re `.*(any key to continue|tecla para continuar).*'? No +. pattern #6: -re `.*ffending .*key in (.+?)\\:(\\d+).*'? No. pattern #7: -re `([lL]ogin|[uU]suario|([uU]ser-?)*[nN]ame.*|[uU]ser) +\\s*:\\s*$'? No. pattern #8: -re `([pP]ass|[pP]ass[wW]or[dt](\\s+for\\s+|\\w+@[\\w\\- +\\.]+)*|[cC]ontrase.a|Enter passphrase for key \'.+\')\\s*:\\s*$'? No +. pattern #9: -re `(([#%:>~\\$\\] ])(?!\\2)){3,4}|([\\w\\-\\.]*)\\$ *$ +|\\w[@\\/]\\w.*?[#%>~\\$\\]]|^[#%\\$>\\:]~] *$'? YES!! Before match string: `############################################ +##################################\r\n# This system is a restricted a +ccess system. ' Match string: ` #' After match string: `\r\n# If collected security information revea +ls possible criminal activity that #\r\n# exceeds privileges, eviden +ce of such activity may be provided to the rele- #\r\n# vant authorit +ies for further action. By continuing past this point, you #\r\n# +expressly consent to this security monitoring. + #\r\n########################################################## +####################\r\n\r\n\r\nhostname: ~# ' Matchlist: (`#', `#', `') Calling hook CODE(0x55f2fb33fe20)...

In reply to Problem with regex is a bug? or my regex by hanspr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2022-05-25 13:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (90 votes). Check out past polls.

    Notices?