Trim Characters Functionality

Comments

8 comments

  • Avatar
    michiel

    You could use <setInstallerVariableFromRegex> to trim the first four characters:

     <setInstallerVariableFromRegEx>
    <name>trimmed</name>
    <text>1234-56789</text>
    <pattern>"^(....).*</pattern>
    <substitution\1<substitution/>
    </setInstallerVariableFromRegEx>

     

  • Avatar
    Jake

    Thanks, I was able to get it using something like this this: 

    <setInstallerVariableFromRegEx>
        <name>value1</name>
        <pattern>^(.*?)-(.*?)$</pattern>
        <substitution>\1</substitution>
        <text>${value}</text>
      </setInstallerVariableFromRegEx>
  • Avatar
    BitRock support

    It's great to hear you found a solution.

  • Avatar
    Jake

    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 "1234-5678-9012", which is "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>
  • Avatar
    michiel

    Can you try this pattern?

    <setInstallerVariableFromRegEx>
        <name>value1</name>
        <pattern>^[0-9-]{0,7}</pattern>
        <substitution>\1</substitution>
        <text></text>
      </setInstallerVariableFromRegEx>

     

     

  • Avatar
    Tam Bui

    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

  • Avatar
    michiel

    Hi Tam,

    Sorry, I misunderstood your question. Could you try this instead:

    <setInstallerVariableFromRegEx>
        <name>value1</name>
        <pattern>^([0-9-]{0,7}).*$</pattern>
        <substitution>\1</substitution>
        <text></text>
      </setInstallerVariableFromRegEx>

     

  • Avatar
    Jake

    Thanks! this works for me.

Please sign in to leave a comment.