You are not logged in.
Pages: 1
Using a regex to select everything before a character:
The values we receiving from the Client on the Server tag is not always the same :
Exsamples:
<Server>BDHPAM01 Source:BJHVMH01</Server>
<Server>BDHPAM02_Source:BJHVMH01</Server>
<Server>BDHPAMSource:BJHVMH01</Server>
I only want the "BJHVMH01" value.
This is how I was able to get the correct values by using a regex.
I used a regex "^(.*?)\:" to select everything before a character ":" and Replacing it with nothing giving me the value of "TJHVMH01".
<sxi:Field name="mServer">
<sxi:Rules>
<sxi:Substitute>
<!-- regex to select everything before ":" -->
<sxi:Find>^(.*?)\:</sxi:Find>
<sxi:Replace></sxi:Replace>
</sxi:Substitute>
</sxi:Rules>
<sxi:OutputField>Server</sxi:OutputField>
</sxi:Field>
There is a couple ways this can be done ....
Please add to this post how you will do it.
Offline
Is there a reason you didn't simply split on the ":" and put element [1] into an output field?
Offline
Yes, when we get the following two values and do a split on the "\" and ":" we get Index 0.
"RFSSQL21\SQL1QBS" -----> RFSSQL21 = Index 0
"BDHPAM02Source:BJHVMH01" -----> BDHPAM02Source = Index 0,
I need the "BJHVMH01" value by doing a substitute find replace with the regex "^(.*?)\:" will give the correct value "BJHVMH01"
Example :
<sxi:Field name="mServer">
<sxi:Rules>
<sxi:Split>
<sxi:Delimiter>\\</sxi:Delimiter>
<sxi:OutputFields>
<sxi:OutputField index="0">TmpServer</sxi:OutputField>
</sxi:OutputFields>
</sxi:Split>
<sxi:TrimAllBlanks/>
</sxi:Rules>
<sxi:OutputField>Omit</sxi:OutputField>
</sxi:Field>
<sxi:Field name="TmpServer">
<sxi:Rules>
<sxi:Substitute>
<sxi:Find>^(.*?)\:</sxi:Find>
<sxi:Replace></sxi:Replace>
</sxi:Substitute>
</sxi:Rules>
<sxi:OutputField>Server</sxi:OutputField>
</sxi:Field>
Offline
This still doesn't explain why you are not doing a second split.
E.g.
<sxi:Field name="mServer">
<sxi:Rules>
<sxi:Split>
<sxi:Delimiter>\\</sxi:Delimiter>
<sxi:OutputFields>
<sxi:OutputField index="0">TmpServer</sxi:OutputField>
</sxi:OutputFields>
</sxi:Split>
<sxi:TrimAllBlanks/>
</sxi:Rules>
<sxi:OutputField>Omit</sxi:OutputField>
</sxi:Field>
<sxi:Field name="TmpServer">
<sxi:Rules>
<sxi:Split>
<sxi:Delimiter>:</sxi:Delimiter>
<sxi:OutputFields>
<sxi:OutputField index="1">Server</sxi:OutputField>
</sxi:OutputFields>
</sxi:Split>
</sxi:Rules>
<sxi:OutputField>Omit</sxi:OutputField>
</sxi:Field>
If you want to use regex perhaps provide the full source field example and we can look at one step to get the value you need.
Offline
Pages: 1