how to find the position of a substring in a string?

  • 7 August 2015
  • 4 replies
  • 55 views

Badge +4

Is it possible to get the position of a substring in a string on a form?

Has anyone ever needed this and succeed in finding a solution?

 

thank you

adriana


4 replies

Badge +11

Vadim Tabakman has a post about this for the workflows - Nintex Workflow - InStr Inline Function - Vadim Tabakman

There have been talks about adding this as a feature within nintex as well, please vote here if you feel like:A fn-find() so that you can find the first position of a character or string. – Customer Feedback for Nintex

In the form, if you can try to perform search() then you can use the below function:

function findstr()

{

var str = NWF$('#'+Sentence);

var n = str.search("my");

alert(n.val());

}

where Sentence is the returned ID from the text field and the button to retrieve the value calls the function findstr().

Someone else would have more ideas about it.

Badge +4

Thank you for this answer.

I really need this to be on the form... so the workflow will not help me, and I need to perform this search on a specific string- like a single line of text as the value i am looking for appears in more than one place on the form.

I have tried with the findstr() function but it doesn't work.

thank you

Badge +9

Hi adriana

 

in Forms you can get the position using a formula:

my_text and my_substr are single line Textbox controls, the position is computed in a calculated value control with formula:

length(replace(my_text, my_substr + '.*', ''))

 

Kind regards

Manfred

Badge +4

it works!!!! thank you!!!!

it is wonderful:)

Reply