• 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
    Midrange Dynamics North America

    With MDRapid, you can drastically reduce application downtime from hours to minutes. Deploying database changes quickly, even for multi-million and multi-billion record files, MDRapid is easy to integrate into day-to-day operations, allowing change and innovation to be continuous while reducing major business risks.

    Learn more.

    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

  • Meet The Next Gen Of IBMers Helping To Build IBM i
  • Looks Like IBM Is Building A Linux-Like PASE For IBM i After All
  • Will Independent IBM i Clouds Survive PowerVS?
  • Now, IBM Is Jacking Up Hardware Maintenance Prices
  • IBM i PTF Guide, Volume 27, Number 24
  • Big Blue Raises IBM i License Transfer Fees, Other Prices
  • Keep The IBM i Youth Movement Going With More Training, Better Tools
  • Remain Begins Migrating DevOps Tools To VS Code
  • IBM Readies LTO-10 Tape Drives And Libraries
  • IBM i PTF Guide, Volume 27, Number 23

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