From your regex, it looks like it would capture all numbers down to where it hits the "~" character? You are using "\d*" which means it will capture as many digits there are before a different character turns up, or the value ends. The asterisk means "repeat zero or more times", and it is "greedy", so will repeat as many times as possible. Can you please clarify what your desired result is?
Correct, I don't believe the expression is the problem. Let's walk through an example using the data above:
This expression "[C][A][S]\*[P][R]\*(\d)\*(\-?\d+\.?\d*)" will capture lines 2, 4, 5, & 6. In Monarch, the potential selection turns a dark yellow and allows you to right click and create a template from selection. When I do that for the dollar amount (i.e. 1216, 55.06, -17.13, etc), the 1216 will be fully selected but the 55.06 will only partially be selected using the first 4 characters - "55.0" (as would the "-17."). So my goal is to return the entire dollar amount without having to expand my template width and use a calculated field. Does that clarify my problem?
I apologize for detailed language above, the goal was to make it easier to understand for someone other than yourself who might not have your knowledge! I appreciate the help.
When dealing with regex, I don't think template width matters. Using your example, I was able to use this regular expression:
And i was able to capture:
You might need to change the option next to the regular expression trap type to explicit capture
Hope this helps, or let me know if you have any questions about the regex above.
I certainly appreciate you cleaning the expression up for me, I'm still very green with writing clean syntax. I tried your expression and it highlighted both fields (I also checked Explicit Capture - do you care to explain what this does?). I right clicked on the amount and created a field from that capture. However, I'm still only getting four characters in length. Did you create the capture a different way?
It correctly highlighted the correct amount of characters, it's when I go to create a field is when the length is stagnate.
I found that by simply increasing the template size in the field settings, it included all amounts of varying lengths. I believe it is safe to call this issue solved. Chris, I really appreciate the help on this!
The explicit capture basically means to capture exactly what is being defined in the regex, so it is not forgiving in regards to case sensitivity, white space, etc.
I might take back what I said about the template width not mattering. You should make it as long as you think you are going to need it. On my model, I had set it to 11 so the right values were displaying correctly. If I set it to 4, it would truncate some of the numbers and not give me the right results, which makes sense now that I think about it.
The regex is going to grab exactly what you defined. If the template width is set to 4, then only 4 "characters" and your trap pulled in 8 characters, then only 4 characters from that trap will be used for the field value. If the template width is set to 100 but the trap pulled in 8 characters, then all 8 characters will be used.