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
14
votes
6 answers

Replacing single '\' with '\\' in Java

How do I replace a single '\' with '\\'? When I run replaceAll() then I get this error message. Exception in thread "main" java.util.regex.PatternSyntaxException: Unexpected internal error near index 1 \ …
Husain Sanwerwala
  • 479
  • 2
  • 7
  • 13
6
votes
1 answer

Android optional word boundary regex

I'm having trouble with a regular expression when targeting the Android platform 2.2.3. The following regular expression works when targeting the Java VM on my desktop and the regular expression is also working on a .NET application…
Tentux
  • 714
  • 1
  • 4
  • 13
5
votes
6 answers

PatternSyntaxException

Following String causes PatternSyntaxException: Pattern.compile("*\\.*"); I want to create a pattern so that I can filter all files with the name in the following form: "*.*" How can I do that?
Caner
  • 57,267
  • 35
  • 174
  • 180
4
votes
1 answer

Android: PatternSyntaxException: Syntax error U_ILLEGAL_ARGUMENT_ERROR

I'm using json-io for converting some JSON data to Java objects: DataTransferContainer dataTransferContainer = (DataTransferContainer)JsonReader.jsonToJava(json); DataTransferContainer is just an object containing some GeoJson elements. It does not…
Bevor
  • 8,396
  • 15
  • 77
  • 141
3
votes
1 answer

rsync --include --exclude simple task doesn't work

I would like to use rsync to download specific files from a server, here are the scheme of the directory: . file1 fakeotherfolder filefile morefile morefakefolder file file2 file3 mainfolder myfolder1 folfile1 …
Romain
  • 1,511
  • 1
  • 10
  • 13
2
votes
1 answer

java - replaceAll() returns PatternSyntaxException

I have this code : buffer = buffer.replaceAll("(",""); That is returning java.util.regex.PatternSyntaxException I don't know why. Help, please.
Khalil Hamani
  • 71
  • 2
  • 3
  • 13
2
votes
4 answers

Java: PatternSyntaxException thrown with regex .*-\\d+{.*}\\d+-.*

I am trying to make a regex to determine if a String contains a -, some amount of digits, a {, nothing/some sequence of characters, a }, some amount of digits, and a final -. For…
James Ko
  • 32,215
  • 30
  • 128
  • 239
2
votes
4 answers

Splitting a Java String on the "+" symbol gives an error

I'm currently writing a java program, one of whose sub-tasks is to take a string and split it at a location. So, here's one little snippet of my code: public class Driver { public static void main(String[] args) { String str =…
QuantumFool
  • 609
  • 3
  • 10
  • 29
1
vote
1 answer

SyntaxException: line 2:10 no viable alternative at input 'UNIQUE' > (...NOT EXISTS books ( id [UUID] UNIQUE...)

I am trying the following codes to create a keyspace and a table inside of it: CREATE KEYSPACE IF NOT EXISTS books WITH REPLICATION = { 'class': 'SimpleStrategy', 'replication_factor': 3 }; CREATE TABLE IF NOT EXISTS books ( id UUID PRIMARY KEY, …
best_of_man
  • 643
  • 2
  • 15
1
vote
1 answer

how pattern syntax exception works

private static final String NAME_REGEX = "^[a-zA-Z]+(([',. -][a-zA-Z ])?[a-zA-Z]*)*$"; private static final Pattern NAME_PATTERN = Pattern.compile(NAME_REGEX); how do I use the following statement in try n catch block to chk if the name is valid…
16v
  • 23
  • 5
1
vote
2 answers

Why is no PatternSyntaxException thrown for my invalid pattern?

I want to test whether a regexp is valid in Java 1.8.0_241 public static boolean isRegExpValid(String regExp) { try { Pattern.compile(regExp); return true; } catch (PatternSyntaxException e) { return false; …
Jose Rui Santos
  • 15,009
  • 9
  • 58
  • 71
1
vote
1 answer

Getting java.util.regex.PatternSyntaxException when using replaceAll method

I'm trying to replace a text using replaceAll method but getting this error Caused by: java.util.regex.PatternSyntaxException: Illegal repetition near index 0 ${rate+0.0020D2} here is my code String regExp =…
user2142786
  • 1,484
  • 9
  • 41
  • 74
0
votes
1 answer

Exception in thread "main" java.util.regex.PatternSyntaxException: Illegal/unsupported escape sequence near index 2

I'm trying to remove some words from the line. I don't want to prescribe them but replace them, because the words that I remove may increase. So I used an array. But when I try to do this, I get errors. I will be glad of any help. String[] a = new…
user19207662
0
votes
1 answer

java.util.regex.PatternSyntaxException while using RowFilter in java swing

filterField.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { String query = filterField.getText().trim(); TableRowSorter sorter = new…
0
votes
0 answers

PatternSyntaxException String split Java

I have this code.... private static final String FS = System.getProperty("file.separator"); private void addPathToTreeFiles(String canonicalFolder, String canonicalFilename) throws Exception { String filename = null; String canonicalPaths =…
joseluisbz
  • 1,491
  • 1
  • 36
  • 58
1
2