Menu

#150 Searching with REGEXPR

3.0
closed
nobody
None
2024-09-21
2024-09-19
Matt Tyler
No

I am having trouble getting a search to return results. When I use this regular expression over source I know has this pattern, I either get results not correct or no results.

I need to find RPGLE members with internal output specs that have a print record with no line spacing.

This is a production source example that does not match, O EF PRTHDR 0

This pattern returns results that I don't want .....O.{37}(0|\s)0 and not the ones I want.
This pattern does not return any results, ^.....O.{37}(0|\s)0.

I have tried reducing the columns to search to 1-46 but this has no effect.

This pattern works in finding *INKx strings, \*INK[A-NPR-Y].

Discussion

  • Matt Tyler

    Matt Tyler - 2024-09-19

    This is a sample source that should demonstrate issue.

     
  • Thomas Raddatz

    Thomas Raddatz - 2024-09-20

    Hi Matt,

    You stumbled about a nasty problem. The regex function available on the IBM i does not follow the well-know expression most people now. Some character classes are different, because regex on the IBM i follows the "Posix/Unix" specification as stated by IBM support.

    One of the nasty differences is that \s (white spaces) must be expressed as [[:space:]].

    I described that in the iSphere help: iSphere > Reference > Stream File Search

    The question mark (?) next to the "Regular expression" label on the "iSphere Source File Search" dialog is a link that takes you to the regex help page.

    On my opinion, the following expressions should be best:

    ^[[:space:]]{5}O.{37}(0|[[:space:]])0
    

    At least it returns the expected result:

    Line 5:
         O          EF           PRTHDR         0
    

    Thank you for the example source. That is how I like it.

    Thomas.

     

    Last edit: Thomas Raddatz 2024-09-20
  • Matt Tyler

    Matt Tyler - 2024-09-20

    Ugg, of course I would forget about that. Normally, I use VSCode but it does not have a search using reg expressions over IBM i members.

    Thanks for the reminder.

     
  • Thomas Raddatz

    Thomas Raddatz - 2024-09-21
    • status: open --> closed
     
  • Thomas Raddatz

    Thomas Raddatz - 2024-09-21

    Hi Matt,

    No problem at all, you are welcome.

    As long as I remember the details, everything is fine. Just kidding.

    Thomas

     

    Last edit: Thomas Raddatz 2024-09-21

Log in to post a comment.

MongoDB Logo MongoDB