• 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
    Manta Technologies

    The Leader in IBM i Education!
    Need training on anything i?
    Manta is all you need.

    130 courses and competency exams on:
    · IBM i operations
    · System Management and Security
    · IBM i Programming Tools
    · Programming in RPG, COBOL, CL, Java
    · Web Development

    SQL, DB2, QueryProduct features:
    · Runs in every popular browser
    · Available 24/7/365
    · Free Student Reference Guides
    · Free Student Administration
    · Concurrent User License
    · Built-In IBM i Simulator

    You can download our 200-page catalog and take sample sessions at MantaTech.com

    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