Expand my Community achievements bar.

SOLVED

Numberical value in a paragraph of text

Avatar

Level 5

I have a LiveCyle document Text Field (Text Field titled "Subject") that is filled with text similar to the following.

"Thank you for your recent contact with XYZ company. We have enclosed form E12-XX and evaluted your offer. We find after consideration of your submittal to XYZ we are able to fufill your offer for $XXX.XX with a finish date of XXXX XX, 20XX....."

This paragraph is dynamic, however the paragraph usually stays in the same order. Meaning the greeting, wording, then a form number E12-XX and so on are in this general order. Of course "XX" in E12-XX can be many possibilites as well as the price and date.

How do I write the javascript to copy only the form number "E12-XX" from this "SUBJECT" text field and paste to another "FORMNUMBER" text field? Below is what I'd like the form to do on its own.

SUBJECT TEXT FIELD

"Thank you for your recent contact with XYZ company. We have enclosed form E12-89 and evaluted your offer. We find after consideration of your submittal to XYZ we are able to fufull your offer for $178.29 with a finish date of April 19, 2008.....

FORMNUMBER TEXT FIELD

E12-89

Thank you for your help.

1 Accepted Solution

Avatar

Correct answer by
Level 8

Try this:

var pattern = /\bE\d{2}-\d{2}\b/g;

var aValues=pattern.exec(SubjectTextField.rawValue);

FormNumberTextField.rawValue=aValues[0];

Kyle

View solution in original post

2 Replies

Avatar

Correct answer by
Level 8

Try this:

var pattern = /\bE\d{2}-\d{2}\b/g;

var aValues=pattern.exec(SubjectTextField.rawValue);

FormNumberTextField.rawValue=aValues[0];

Kyle

Avatar

Level 5

The above formula works great if the digits will only be two numbers, i.e. E12-87 but not if you need to get E12-172. I changed (see bolded 2,3) the first line of javascript to the formula below to include numbers 01 thru 999, i.e. E12-109. The code seems to work fine.

var pattern = /\bE\d{2}-\d{2,3}\b/g;

var aValues=pattern.exec(Page1.Subject.rawValue);

MP3.FormNumber.raw.Value=aValues[0]    

Page 1= Parent Page Name

MP3=Master Page Three name renamed MP3

Subject=Text Field Name