You are viewing limited content. For full access, please sign in.

Question

Question

How to use regular expression with javaScript page on LF Forms 9.2?

asked on October 19, 2014

Here is my javaScript code

              mytext ="123|xxx|200|sss"
                     temp = /\|(\w*)\|/.exec(mytext);
                     $('.MyData input').val(temp);

I just want something between | |  to display on MyData field.

Ouput is:

|xxx|,xxx

But the result I want is only "xxx"

Is It possible to do this with field in javaScript page.on LF Forms.

Regards

bongkoch

regular_expression_issue_001.png
0 0

Answer

SELECTED ANSWER
replied on October 20, 2014

This might help a bit: 

 

http://www.w3schools.com/jsref/jsref_match.asp

http://www.w3schools.com/js/js_arrays.asp

 

The match function returns an Array as your result. The [0] slot is always what you searched for. Any matches happen in later slots.

 

So in your example you always are only expecting what's in slot [1], so you'd need to add the following:

 

                     mytext ="123|xxx|200|sss"
                     tempMatch = /\|(\w*)\|/.exec(mytext);
                     temp = tempMatch[1];
                     $('.MyData input').val(temp);

At least I think it would be. I don't have something up to test right now. :)

1 0
replied on October 21, 2014

Hi Chris,

Thank you for your help.

I have to learn a lot about jquery.

Appriate this.

Bongkoch

1 0

Replies

You are not allowed to reply in this post.
You are not allowed to follow up in this post.

Sign in to reply to this post.