Substr and Index

Substr and Index

  
Hello everyone!
In my espace i have one parameter with, for example: 15-18. And i want get the number before hifen and the number after hifen.

For number before hifen i used :Substr(IDs,0,Index(IDs,"-")-1) and workly.
With Substr and Index, can i get the number after hifen? How?

Best Regards, Paulo Torres
Hi Paulo,

You can get the number after the hifen using : Substr(IDs,Index(IDs,"-")+1,Length(IDs)).

Regards,
Nelson Baptista
Hi Paulo,

If your sure that the number after the hifen always has 2 chars, then you can use:

Substr(IDs,Index(IDs,"-")+1,2)

If you don't know how much chars exists after the hifen, then you can use:

Substr(IDs,Index(IDs,"-")+1,Length(IDs)-Index(IDs,"-")+1)

Hope this helps.

Cheers,

Nelson Freitas
Thank you very much NelsonS :)
All solutions works, i only have to choose one!!

If i have in parameter 13-15-19, how i get the third number??

Thank you very much my friends

Paulo Torres
Paulo,

the Index(string,search)  function returns the first position where the search is found. To find the last position, you can use the String_LastindexOf that exists on the Text extension i'm sure you use somewhere in your platform (because its installed).

So, you can use the same previously code, but instead of using the Index function, you use the String_LastIndexOf

Cheers,

Nelson Freitas
Hi Paulo,

Add the "searchFromEnd" optional parameter in the Index(IDs,"-") part.

Hope it helps,

HD
Oh,

Helio is right too. I assumed you were not using Outsystems lastest version. In the 6.0 version, the Index function has several inputs that you can play with. The previous versions (never use that function on 5.1) just has the first 2 inputs and thats why I mentioned the String_LastIndexOf.

Cheers mate,

Nelson Freitas
Hi Paulo, 
Try this:

Action: String_Split("13-15-19", "-") 
Assign: Value = String_Split.List[1].Text.Value



String_Split action is part of text extension

Regards, 
RD

[2] :)
Rui David wrote:
Hi Paulo, 
Try this:

Action: String_Split("13-15-19", "-") 
Assign: Value = String_Split.List[1].Text.Value



String_Split action is part of text extension

Regards, 
RD
 
 
 Thanks Rui.
Your picture helps me a lot :)

Hugs