Java.lang.indexoutofboundsexception: No Group 1

Posted : admin On 12.09.2019
  1. Java Create Matcher
Java lang indexoutofboundsexception pyspark

Java Create Matcher

Java.lang.IndexOutOfBoundsException: No group pattern matching(I'm documenting this for the database)per this page:Aware's REPLACEPATTERN 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.'

I'm trying to extract the district of some postcodes using regex with the following script in Pyspark:postcodes.select('rawpostcode', regexpextract('rawpostcode', '^a-zA-Z+dd?a-zA-Z?' , 1).alias('area')).show(40, False)I get following exception: Py4JJavaError: An error occurred while calling o562.showString.: org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 17.0 failed 4 times, most recent failure: Lost task 0.3 in stage 17.0 (TID 44, ip-172-31-100-215.eu-west-1.compute.internal, executor 1): java.lang.IndexOutOfBoundsException: No group 1at java.util.regex.Matcher.group(Matcher.java:538)I have tried the regex in Python alone and it works, but it is giving me trouble in pyspark. Help me find out the reason.

Group(1)是取字符后的数字,可能如果没有时,就出错了,但是不知怎么屏蔽这个错 追答 你的matcher表达式发一下,还有要匹配的字符串模型发一下。.