RegEx plugin - RFE

I just tried out the RegEx plugin to aid in creating a pattern for matching
a US phone number.

Excellent plugin! It works great.

My only suggestion would be to enhance the Reference to include a comment
about using $1, $2, $3, ... for capture groups in the replacement text.

I know, it's in another part of the javadoc; and I fully understand the
usage after scouring the javadoc and participating in some interesting
discussions in another IDEA forum. However, for the sake of people that are
new to the java implementation of RegEx, it would be very convenient if the
Reference that is displayed to the user explained the format of the
replacement text. After all, if you are a java RegEx guru, you don't need
the RegEx plugin.

Thanks again for an excellent plugin.

Tim


2 comments
Comment actions Permalink

Tim Haley wrote:

My only suggestion would be to enhance the Reference to include a comment
about using $1, $2, $3, ... for capture groups in the replacement text.

good idea ... will include a small portion of $ in the next release.
thanks for the rfe.
do you have a better idea on how to structure the reference .. its
pasted straight from the javadoc and i dont know if this is soo clever.

cK

0
Comment actions Permalink

cK,

The javadoc for java.util.regex.Matcher.appendReplacement(StringBuffer,
String) includes the following description:

"The replacement string may contain references to subsequences captured
during the previous match: Each occurrence of $g will be replaced by the
result of evaluating group(g). The first number after the $ is always
treated as part of the group reference. Subsequent numbers are incorporated
into g if they would form a legal group reference. Only the numerals '0'
through '9' are considered as potential components of the group reference.
If the second group matched the string "foo", for example, then passing the
replacement string "$2bar" would cause "foobar" to be appended to the string
buffer. A dollar sign ($) may be included as a literal in the replacement
string by preceding it with a backslash (\$)."

You could use that. Although you might want to include the following from
the java.util.regex.Matcher.group(int) javadoc:

"Capturing groups are indexed from left to right, starting at one. Group
zero denotes the entire pattern"

I have no problem with the cut & paste from the javadoc. It is clear enough
and familiar to most java developers.


Thanks,

Tim


"Christian Köstlin" <gizmo@flopcode.com> wrote in message
news:c9kvrq$c03$1@is.intellij.net...

Tim Haley wrote:

>

My only suggestion would be to enhance the Reference to include a

comment

about using $1, $2, $3, ... for capture groups in the replacement text.

good idea ... will include a small portion of $ in the next release.
thanks for the rfe.
do you have a better idea on how to structure the reference .. its
pasted straight from the javadoc and i dont know if this is soo clever.

>

cK



0

Please sign in to leave a comment.