• 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
    WorksRight Software

    Do you need area code information?
    Do you need ZIP Code information?
    Do you need ZIP+4 information?
    Do you need city name information?
    Do you need county information?
    Do you need a nearest dealer locator system?

    We can HELP! We have affordable AS/400 software and data to do all of the above. Whether you need a simple city name retrieval system or a sophisticated CASS postal coding system, we have it for you!

    The ZIP/CITY system is based on 5-digit ZIP Codes. You can retrieve city names, state names, county names, area codes, time zones, latitude, longitude, and more just by knowing the ZIP Code. We supply information on all the latest area code changes. A nearest dealer locator function is also included. ZIP/CITY includes software, data, monthly updates, and unlimited support. The cost is $495 per year.

    PER/ZIP4 is a sophisticated CASS certified postal coding system for assigning ZIP Codes, ZIP+4, carrier route, and delivery point codes. PER/ZIP4 also provides county names and FIPS codes. PER/ZIP4 can be used interactively, in batch, and with callable programs. PER/ZIP4 includes software, data, monthly updates, and unlimited support. The cost is $3,900 for the first year, and $1,950 for renewal.

    Just call us and we’ll arrange for 30 days FREE use of either ZIP/CITY or PER/ZIP4.

    WorksRight Software, Inc.
    Phone: 601-856-8337
    Fax: 601-856-9432
    Email: software@worksright.com
    Website: www.worksright.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

  • Public Preview For Watson Code Assistant for i Available Soon
  • COMMON Youth Movement Continues at POWERUp 2025
  • IBM Preserves Memory Investments Across Power10 And Power11
  • Eradani Uses AI For New EDI And API Service
  • Picking Apart IBM’s $150 Billion In US Manufacturing And R&D
  • FAX/400 And CICS For i Are Dead. What Will IBM Kill Next?
  • Fresche Overhauls X-Analysis With Web UI, AI Smarts
  • Is It Time To Add The Rust Programming Language To IBM i?
  • Is IBM Going To Raise Prices On Power10 Expert Care?
  • IBM i PTF Guide, Volume 27, Number 20

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