Hi,
I would like to ask what is the best way to trim characters in IB? For example, with string ' 1234-456789' , I only want to look the first 4 characters, how would I trim that out? I saw <stringModify>, but I don't see it has something like this?
You could use <setInstallerVariableFromRegex> to trim the first four characters:
<setInstallerVariableFromRegEx>
<name>trimmed</name>
<text>1234-56789</text>
<pattern> or ' ^(....).*</pattern>
<substitution or or 1<substitution/>
</setInstallerVariableFromRegEx>
Thanks, I was able to get it using something like this this:
<setInstallerVariableFromRegEx> <name>value1</name> <pattern>^(.*?)-(.*?)$</pattern> <substitution> or or 1</substitution> <text>${value}</text> </setInstallerVariableFromRegEx>
It's great to hear you found a solution.
Hello,
Related to this optic, can you help me how I trim the first 6 or 7 char?
For example, if I want the first 7 char of or ' 1234-5678-9012 or ' , which is or ' 1234-56:. What would be the pattern and substitution logic? I've tried a few (like below) without success.
<pattern>^[0-9]{0,6}$</pattern>
Can you try this pattern?
<setInstallerVariableFromRegEx> <name>value1</name> <pattern>^[0-9-]{0,7}</pattern> <substitution> or or 1</substitution> <text></text> </setInstallerVariableFromRegEx>
Hi,
I've tried that, but I got the last 7 digit instead of the first 7.
Whole Narrow: 7746-1810-8801
Info: Narrow: 10-8801
Hi Tam,
Sorry, I misunderstood your question. Could you try this instead:
<setInstallerVariableFromRegEx> <name>value1</name> <pattern>^([0-9-]{0,7}).*$</pattern> <substitution> or or 1</substitution> <text></text> </setInstallerVariableFromRegEx>
Thanks! this works for me.