Substring after a last special character - InfoPath Dev
in

InfoPath Dev

Substring after a last special character

Last post 05-25-2007 01:33 PM by anotherchrisberry. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 05-23-2007 08:19 AM

    Substring after a last special character

    Hi all,

    I have an field ID (sample T123-ABC-DEF-GHI-JKL-CC). How can I get the substring afte the last character "-"? I need the substring "CC".

    Thank for your help.
     

  • 05-23-2007 11:59 AM In reply to

    Re: Substring after a last special character

    Are there always the same number of characters or the same number of "-"?

    If so you could use the substring length or nested substring-after functions.

    There are quite a few examples on the site here.

  • 05-23-2007 12:35 PM In reply to

    Re: Substring after a last special character

    You could use the LastIndexOf method of the string to find the position of the last "-" and then use the substring method to get the string from the last index to the end of the string.. here is an example.

    string test = T123-ABC-DEF-GHI-JKL-CC;

    int position = test .LastIndexOf( "-" );

    string temp = test .Substring( position ); // you may have to say position + 1 here not sure.

    int position = test .LastIndexOf( "-" );

    string temp = test .Substring( position ); // you may have to say position + 1 here not sure.

    string temp = test .Substring( position ); // you may have to say position + 1 here not sure.
  • 05-25-2007 01:50 AM In reply to

    Re: Substring after a last special character

    Thanks for your replies. 

    The length of the string is variable. I have to get the substring after the last character ("-") in a rule.

    Via code I know how can I solve this problem but via rule I don't know. 

  • 05-25-2007 01:33 PM In reply to

    Re: Substring after a last special character

    Is the length of the substring variable? If it's always two or three characters, you could use something like this:

    substring-after(substring(ID, (string-length(ID)-3)), "-")

Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.