propertyregex ANT task - need to extract string without newline character

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

propertyregex ANT task - need to extract string without newline character

forumUsr
Hello

I have following ANT task where I like to extract string starting from a
keyword until newline character:

<java classname="org.eclipse.jetty.util.security.Password"
outputproperty="tmp_fnd0_Password">
<arg value="${fnd0_Password}"/>
<classpath refid="jetty.password.util.path"/>
</java>

<propertyregex property="obfuscated_fnd0_Password"
input="${tmp_fnd0_Password}" regexp="OBF:.*" select="\0" global="true"
casesensitive="true" />


             <replace file="${root_path}/pool_manager/confs/${config.id
}/test_file.xml">
                            <replacefilter token="@CHANGE_ME_PASSWORD@"
value="${obfuscated_fnd0_Password}"/>
              </replace>

Java ANT task results in following output:


2020-10-14 13:55:00.549:INFO::pool-2-thread-1: Logging initialized @25148ms
to org.eclipse.jetty.util.log.StdErrLog
XXXX
OBF:1uha1v9q1tvn1zep1XXXXXXv8w1ugg
MD5:2a72dd47fe552bcdd07ace50e9047baf

Propertyregex ANT task generates output:
OBF:1uha1v9q1tvn1zep1XXXXXXv8w1ugg

My suspicion is Propertyregex output has a newline character as well,
because  test_file.xml has the expected string along with the newline
character.
test_file.xml:
  <Set name="Password"><Property name="Password" deprecated="password"
default="OBF: 1uha1v9q1tvn1zep1XXXXXXv8w1ugg
"/></Set>


Is there a way for me to skip the newline character ?  I thought
regexp="OBF:.*"  will select string from OBF: and .* will match any
character ( except for line line terminator )

Any help would be greatly appreciated.

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: propertyregex ANT task - need to extract string without newline character

KM-2
I am not sure if the regex works the same as some of the others, but you could try "$" at the end after the asterisk.  Maybe like regexp="OBF:.*$"

KM




On Thursday, October 15, 2020, 12:01:44 PM EDT, forumUsr forumUsr <[hidden email]> wrote:





Hello

I have following ANT task where I like to extract string starting from a
keyword until newline character:

<java classname="org.eclipse.jetty.util.security.Password"
outputproperty="tmp_fnd0_Password">
<arg value="${fnd0_Password}"/>
<classpath refid="jetty.password.util.path"/>
</java>

<propertyregex property="obfuscated_fnd0_Password"
input="${tmp_fnd0_Password}" regexp="OBF:.*" select="\0" global="true"
casesensitive="true" />


            <replace file="${root_path}/pool_manager/confs/${config.id
}/test_file.xml">
                            <replacefilter token="@CHANGE_ME_PASSWORD@"
value="${obfuscated_fnd0_Password}"/>
              </replace>

Java ANT task results in following output:


2020-10-14 13:55:00.549:INFO::pool-2-thread-1: Logging initialized @25148ms
to org.eclipse.jetty.util.log.StdErrLog
XXXX
OBF:1uha1v9q1tvn1zep1XXXXXXv8w1ugg
MD5:2a72dd47fe552bcdd07ace50e9047baf

Propertyregex ANT task generates output:
OBF:1uha1v9q1tvn1zep1XXXXXXv8w1ugg

My suspicion is Propertyregex output has a newline character as well,
because  test_file.xml has the expected string along with the newline
character.
test_file.xml:
  <Set name="Password"><Property name="Password" deprecated="password"
default="OBF: 1uha1v9q1tvn1zep1XXXXXXv8w1ugg
"/></Set>


Is there a way for me to skip the newline character ?  I thought
regexp="OBF:.*"  will select string from OBF: and .* will match any
character ( except for line line terminator )

Any help would be greatly appreciated.

Thanks.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]