× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I've learned in the past that the regular expression style used by the LPEX editor can be found in the Java API docs under java.util.Regex.Pattern. However, back references are $n rather than \n. There may be other differences, but I've not seen any more.

The regular expression I would use for a single source member would be something like this (copy line below, go to source member, press ESC to access LPEX command line, paste the findText line, press ENTER, use ENTER to view next while cursor is in the LPEX command line, press ESC to exit LPEX command line):
    findText regularExpression ^(?!.{6}\*)(?!.{6}\s*//)(.*((\*dmy)|(\*cymd)|(\*ymd)).*)$

Unfortunately this doesn't help you search through multiple source members or source files,  so the scripting that Buck was doing with egrep still ranks higher. Could regular expressions like this be added to PDM or to iSphere's search tool?


Paul.


-----Original Message-----
From: WDSCI-L [mailto:wdsci-l-bounces@xxxxxxxxxxxx] On Behalf Of Buck Calabro
Sent: 18 May 2015 23:07
To: wdsci-l@xxxxxxxxxxxx
Subject: Re: [WDSCI-L] Bulk source search ignoring commented-out code (iSphere special?)

On 5/18/2015 2:22 PM, Dan wrote:
> I posted a similar message in Midrange-L, but then remembered 
> iSphere's Source File Search, and wondered if the function I'm looking 
> for (below) could be integrated into this.
> 
> I need to do a bulk search of source (ala FNDSTRPDM) but with the 
> ability to ignore all comments.
> 
> I'm guessing this is custom-written app, but it seems to be that this 
> would be a valuable tool for many programmers, especially for those in 
> shops where code is never deleted outright, but is commented-out.

pullhairout.gif

> Specifically, I am looking for all usages of '*MDY' (and other formats 
> utilizing 2-digit years).
> 
> Has someone already invented this wheel?

Wow, this turned out to be ugly.  I used to think I understood regular expressions in RDi but I have been disabused of that notion.  I'm half of a mind to call in a support ticket to try to figure out exactly what regex engine RDi is using because the standard Java (?!) lookahead doesn't seem to be working for me.  This finds comments:

findText regularExpression ^(.{6}\*.*|.*\/\/.*)$

I would have thought (ooooh, there's the problem!) that this would have found anything but the comments:

findText regularExpression ^(?!.{6}\*.*|.*\/\/.*)$

Instead, I get a "" not found.

IBM i search does not appear to support regex.
Remote search looks like it should; I tried the regex that found comments (the first one I posted) but it didn't find anything.
Different regex engine?
I don't know how File Search is supposed to work; it has a regular expression box.




So, my mind turns to IBM i, where the source resides anyway.

I almost did it in Code, but who except me has that loaded anymore?  So I went to Cygwin to try out sed/grep/awk and had a lovely go with sed -r '/^......\*.*|^.*\/\/.*|nysut/d' greptest.rpgle which was great except that the sed I have on my IBM i machine doesn't understand -e.  So I just did some tinkering in QShell.

It turns out I have an egrep in /QOpenSys/usr/bin.  It may be part of the YiPS stuff or it may be part of 5799-PTL; I can't remember.  Anyway, this bit of arcana worked:

cat /qsys.lib/prodlib.lib/qrpglesrc.file/greptest.mbr | egrep -v '^......\*.*|^.*\/\/.*' | grep -i '*mdy'

Wrap that in a for...do loop and you can scan an entire source file:

for file in /qsys.lib/prodlib.lib/qrpglesrc.file/*; do echo $file; cat $file | egrep -v '^......\*.*|^.*\/\/.*' | grep -i '*mdy'; done




The for...do...done makes a list of files (members) and DOes the stuff until the DONE.  The stuff in the middle is an

echo $file which prints the full member name

cat $file 'prints' the contents of the source member which gets piped into:

egrep which looks for
^ start of line
...... 6 characters
\* the literal *
.* any number of characters
| - or -
^ start of line
.* any number of characters
\/\/ the literal //
.* any number of characters

This filters out (-v) the comments.

That then gets piped into grep which does a case insensitive search (-i) for *mdy.

--
  --buck

--
This is the Rational Developer for IBM i / Websphere Development Studio Client for System i & iSeries  (WDSCI-L) mailing list To post a message email: WDSCI-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/wdsci-l
or email: WDSCI-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at http://archive.midrange.com/wdsci-l.
---------------------------------------------------------------------------------------
 This email has been scanned for email related threats and delivered safely by Mimecast.
 For more information please visit http://www.mimecast.com
---------------------------------------------------------------------------------------

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.