Questions tagged [patternsyntaxexception]

A PatternSyntaxException is an unchecked exception thrown to indicate a syntax error in a regular-expression pattern.

A PatternSyntaxException is an unchecked exception thrown to indicate a syntax error in a regular-expression pattern.

See the java documentation for more information

26 questions
0
votes
2 answers

Does String.matches() throw anything?

I am using this method to determine whether the input string from a TextField in javafx has this pattern AB123CD with the pattern ("\D{2}\d{3}\D{2}") I am using a try catch enclosure, which catches a (hand)thrown PatternSyntaxException. I am asking…
0
votes
0 answers

How to handle java.util.regex.PatternSyntaxException: Dangling meta character for all the special charcters

I want to handle java.util.regex.PatternSyntaxException: Dangling meta character caused by any special character. For example Assume the following string String var = "Hi * How / are \\ you + "; String replacement =…
Harshita Sethi
  • 2,035
  • 3
  • 24
  • 46
0
votes
2 answers

java.util.regex.PatternSyntaxException: Unclosed character class near index 28

public class samppatmatch { private boolean validatingpswwithpattern(String password){ String math="[a-zA-z0-9]+[(]+(?:[^\\]+|\\.)*"; Pattern pswNamePtrn =Pattern.compile(math); boolean flag=false; Matcher mtch…
0
votes
2 answers

Scanner.nextInt(x) throws PatternSyntaxException

i know im so nooby for asking but please i want to pass my midterm one of the many questions i have a problem with is ""Write an if-else statement that assigns 20 to the variable y if the variable x is greater than 100. Otherwise, it should assign…
0
votes
2 answers

Java regex: [^(\\s?-\\s?)]. PatternSyntaxException on 's'?

I just started learning java regex today so excuse me for taking a rather lazy approach to learning what's wrong with my regex. Basically I'm trying to split a string on 'white space', -, 'white space' pattern (where white space is either one or…
youngrrrr
  • 3,044
  • 3
  • 25
  • 42
0
votes
2 answers

Regex pattern SyntaxException

In my app, I'd like to remove all text in between "example" and the first occurance after this of } from a string. And I want to do this for all occurences. So I use this code: myString.replaceAll("\"example\"(.+?)}", ""); However, this gives me a…
Xander
  • 5,487
  • 14
  • 49
  • 77
0
votes
2 answers

What's wrong with my Groovy regex?

Here's my code: String myRegex = "*cow" String name = "SHIRACOWPEPPER" name = name.toLowerCase() if(!name || name.matches(myRegex)) { return true } When I run this I get a PatternSyntaxException: Dangling meta character '*' near index 0 *cow ^…
DirtyMikeAndTheBoys
  • 1,077
  • 3
  • 15
  • 29
0
votes
1 answer

PatternSyntaxException in java

i am trying to replace the below with ""(Null) java.util.regex.PatternSyntaxException: Syntax error U_REGEX_BAD_INTERVAL near index 50: 01-05 14:11:14.660: E/AndroidRuntime(1546): FATAL EXCEPTION: main 01-05 14:11:14.660: E/AndroidRuntime(1546):…
Goofy
  • 6,098
  • 17
  • 90
  • 156
0
votes
1 answer

Replace all method throws PatternSyntaxException

look at the following code: String comment = "1)FCR pick up in Hong Kong2)Local charges will be paiy in Hong Kong & in…
Srini
  • 420
  • 1
  • 5
  • 17
-2
votes
3 answers

Java error while using replaceAll("+-", "-")

I'm trying to use String.replaceAll but I'm getting an error: Here is my code: public static String signSimplify (String str) { String strr = str.replaceAll("--", "+"); String strr2 = strr.replaceAll("-+", "-"); String strr3 =…
SEVENTH
  • 13
  • 1
-2
votes
2 answers

Unclosed character class near index 525

I'm a new programmer in general, so forgive me if this issue is a fair bit base. This program's goal is a simple calculation of "optimal body weight," and continually throws an exception during runtime over the a and b string comparisons in Line 35.…
Under_Scored
  • 1
  • 1
  • 2
1
2