• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Searching Source In The Twenty-First Century

    October 4, 2016 Ted Holt

    I love it when IBM gives me a way for me to do something I couldn’t do before. When I think of the tools I had to work with three decades ago, I could almost weep. Recently I had to search a source member for a string of characters, and I was overjoyed that LPEX gave me what SEU couldn’t.

    To set the stage for my requirement, I should mention that as a matter of practice, I qualify data structures in my RPG programs. For me to omit the qualified keyword, I have to have a reason.

    dcl-ds  Status       qualified;
       Code              char(2);
       Text              char(24);
    end-ds;
    

    To access a subfield of a qualified data structure requires me to prefix the subfield with the data structure name and a period.

    Status.Code = '20';
    Status.Text = 'Operation completed';
    

    The RPG compiler graciously allows us to leave blanks before and after the period. I assume this is for purposes of readability. At least, that’s the reason I sometimes include blanks.

    Status . Code = '20';
    Status . Text = 'Operation completed';  
    

    How, then, do I search for all instances of the Code subfield of the Status data structure? If I look for “status.code”, the system won’t find the subfield where I left one or more blanks before or after the period. If I leave a blank here or there, the system matches the blanks in the pattern, just as it matches other characters.

    Fortunately, LPEX allows us to use regular expressions when we search.

    The regular expression in my example consists of the following pieces:

    status Look for the string status, ignoring case.
    \s* Zero or more white-space characters
    \. One period. Without the backslash, the period would match any character and the search would find the call to subprocedure StatusXcode.
    \s* Zero or more white-space characters
    code Look for the string code, ignoring case.

    Here are a few more examples of searches using regular expressions.

    status\d Look for status followed by a digit
    ^\s*status Look for lines where status is the first non-blank value.
    code|text Look for <i>code</i> or <i>text</i>, ignoring case.

    You can do a lot, and I do mean a lot, with regular expressions. Regular expressions are cryptic, but they have to be cryptic in order to be so powerful.

    You may as well master regular expressions. They’re not going away any time soon. To learn more about regular expressions, see the links given below.

    Ted Holt welcomes your comments and questions. Email him through the IT Jungle Contacts page.

     

    RELATED STORIES

    Java Regular Expression Patterns

    Regular Expression Library

    Online Regular Expression Tester

     

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags:

    Sponsored by
    OCEAN User Group

    OCEAN TechCon25 Online

    It’s an Exciting Time for IBM i !

    July 16 & 17, 2025 – ONLINE

    Two virtual days of learning, presented by an outstanding group of IBM’ers and IBM Champions, featuring leading-edge topics.

    FREE for OCEAN members!

    Register NOW!

    Annual (12-month) Individual OCEAN Memberships are $80 and a Corporate Membership is $250. A Corporate Membership would allow your entire company to have full access to the OCEAN website & video library and to attend OCEAN events at member rates. Act now because rates are increasing on August 1, 2025.

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Sponsored Links

    BCD:  Webinar: Rapid Node.js Web and Mobile Development with WebSmart. Oct. 6 at 1pm ET. Fresche:  IBM i staffing for all of your IT needs. Request a FREE estimate. 1-800-361-6782 Manta Technologies Inc.:  The Leader in IBM i Education! Download catalog and take sample sessions!

    Two Fall Conferences Are Must-See IT IBM i Tech Refresh Arrives; JSON And Perl In Spotlight

    Leave a Reply Cancel reply

Volume 16, Number 22 -- October 4, 2016
THIS ISSUE SPONSORED BY:

WorksRight Software
COMMON
UCG Technologies

Table of Contents

  • A Style Guide For Modern RPG And ILE, Part 1
  • What’s In A Save File?
  • Searching Source In The Twenty-First Century

Content archive

  • The Four Hundred
  • Four Hundred Stuff
  • Four Hundred Guru

Recent Posts

  • With Power11, Power Systems “Go To Eleven”
  • With Subscription Price, IBM i P20 And P30 Tiers Get Bigger Bundles
  • Izzi Buys CNX, Eyes Valence Port To System Z
  • IBM i Shops “Attacking” Security Concerns, Study Shows
  • IBM i PTF Guide, Volume 27, Number 26
  • Liam Allan Shares What’s Coming Next With Code For IBM i
  • From Stable To Scalable: Visual LANSA 16 Powers IBM i Growth – Launching July 8
  • VS Code Will Be The Heart Of The Modern IBM i Platform
  • The AS/400: A 37-Year-Old Dog That Loves To Learn New Tricks
  • IBM i PTF Guide, Volume 27, Number 25

Subscribe

To get news from IT Jungle sent to your inbox every week, subscribe to our newsletter.

Pages

  • About Us
  • Contact
  • Contributors
  • Four Hundred Monitor
  • IBM i PTF Guide
  • Media Kit
  • Subscribe

Search

Copyright © 2025 IT Jungle