Using the regular expressions for find/replace in the LPEX editor on RDP is confusing. The help text clearly shows that the regular expression patterns should use the details described in the java.util.regex.Pattern javadoc but there are differences that lead to external editors being used for some find/replace operations.
For example, capturing groups should be identified in the "replacement" field as \1, \2, \3, etc. but (by trial and error) I discovered the replacement values to be $1, $2, $3, etc.
Also, the abillity to search including multiple lines (using \n or \R as the newline operator) is missing, but is clearly mentioned in the help text.
At best, the wrong help text is provided. At worst, the implementation of the find/replace feature in RDP's LPEX editor is wrong. Please either provide the relevant help text for the find/replace features implemented, or change the find/replace features to match the help text.
Find/replace is a basic feature of all source code editors, and is a basic necessity in modern programming languages, including RPGLE. Help with regular expressions is often required by novice and expert alike, but the help text provided by RDP is incorrect.
The editor used by Java source and iProjects in RDP uses the regular expression patterns described by its help text, (which, strangely, includes the $1 group replacement value) but the LPEX editors for *RPG*, *CL* and *CBL* source does not.
Example: When converting fixed format RPG to /FREE it is often necessary to replace old RPGIII/RPGIV opcodes with multiple lines that include the replacement BIF usable in /FREE, but this is not possible to do with a regular expression find/replace in RDP as the \n, \r and \R values specified by the help text are not available. Usually I need to cut&paste the source text into a functional source editor (e.g. textpad, notepad++, jEdit, sublime text, etc.) just to do the find/replace I need to do at that moment.
Use Case: A single find/replace with regular expressions shows both problems with the help that I have listed in the description. According to the help page, this should work:
// You have many lines like this and want to convert them into something that works with /FREE
/END-FREE
C 63 ITER
C 76 ITER
/FREE
// ITER is considered bad programming here, but it is an example I found quickly.
// You use: findText replace all noEmphasis regularExpression replaceWith "\1C IF \*IN\2 = \*ON\n\1C ITER\n\1C ENDIF" ^(.....)C\s{3}(\S{2})\s+ITER\s*$
// Multiple backslashes might be required with the findText command, to quote the backslash in the
// \n, \1 and \2 regular expression values, but it doesn't help at all.
// You expect to get this
/END-FREE
C IF *IN63 = *ON
C ITER
C ENDIF
C IF *IN76 = *ON
C ITER
C ENDIF
/FREE
// But you get this
/END-FREE
1C IF *IN2 = *ONn1C ITERn1C ENDIF
1C IF *IN2 = *ONn1C ITERn1C ENDIF
/FREE
// If you use $1 and $2 instead of \1 and \2 in the replacement part of the regular expression
// you get this:
/END-FREE
C IF *IN63 = *ONn C ITERn C ENDIF
C IF *IN76 = *ONn C ITERn C ENDIF
/FREE
If you use the CTRL-F window instead of the findText command (with the same find/replace values as above), you get the same results.
We have reviewed this requirement and we feel it would be a beneficial enhancement to the product. We hope to be able to add it to our development plans in the future.
Due to processing by IBM, this request was reassigned to have the following updated attributes:
Brand - Servers and Systems Software
Product family - Programming Languages
Product - Developer for Power Systems
For recording keeping, the previous attributes were:
Brand - Rational
Product family - Design & development
Product - Developer for Power Systems
This RFE will be under consideration for a future release. Status has been updated to Uncommitted Candidate.
This RFE is consistent with our strategy and product roadmap and IBM is continuing to evaluate.