java.lang.IndexOutOfBoundsException: No group

If you think that something doesn't work in Aware IM post your message here
Post Reply
Jaymer
Posts: 2430
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

java.lang.IndexOutOfBoundsException: No group

Post by Jaymer »

java.lang.IndexOutOfBoundsException: No group pattern matching

(I'm documenting this for the database)

per this page: https://stackoverflow.com/questions/214 ... n-matching

Aware's REPLACE_PATTERN function allows for Regular Expressions.
Thats good, and its bad if you don't need that "extra" umph and just want to replace simple text.

Because if you're inserting, for example, a user's email into a JSON template, there's one thing that can really screw you up.
3-4 months ago I ran across this issue and asked Vlad about it. A User had pasted in this long email and I thought the issue was that it was somehow "too long", and that the Java functions somewhere in the bowels of Aware were hitting a limit. Because if I just hacked off the bottom of the Email (to reduce length), then everything worked fine. Do the full email and it crapped.

(At the time I was having to Base64 encode the Email, which is also why I thought the length was doubling and hitting some limit.)

Turns out that just having something like this in the Email will make it crap out.
"Event Cost: $30"
You'll see it explained in the link, but its because a $ is a special "group character" in Regular Expressions, and it has to be escaped with a \

So, before the "main" RP, I have to do this:
EmailHistory.theMessage =REPLACE_PATTERN( EmailHistory.theMessage , '\x24' , '\x5c\x24' )
EmailHistory.theMessage =REPLACE_PATTERN( EmailHistory.theMessage , '\n' , '')

(the 2nd is to delete any newlines, which will invalidate the JSON - these aren't "returns" that the user adds when typing, as those will get converted to </p>, but depending on where the user created the email and then Pasted into Aware, some <style> blocks may have lines terminated with \n . Some may also need to check for \r . Basically, if you make a REST call, and the Provider rejects it for a reason other than Authentication, yet you think its fine, you can see that JSON payload in Server Output. Copy/Paste that into an online JSON Validator to see if your JSON is ok.)
a1.png
a1.png (12.41 KiB) Viewed 3810 times
a2.png
a2.png (28.29 KiB) Viewed 3810 times
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
Post Reply