Skip to main content
Nintex Community Menu Bar

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

  • August 7, 2015
  • 4 replies
  • 194 views

Forum|alt.badge.img+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

Forum|alt.badge.img+11
  • Scholar
  • August 7, 2015

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.


Forum|alt.badge.img+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


Forum|alt.badge.img+9
  • August 10, 2015

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


Forum|alt.badge.img+4

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

it is wonderful:)