gweg
gweg

Reputation: 2882

Java: correct regex expression for dealing with the following string?

String someXpath = "/a/b/c[3]/preceding-sibling::c[3]/a[2]";
someXpath.replaceAll("/preceding\\-sibling::(.*)\\//", ""));

basically I am trying to get "/a/b/c[3]/a[2]";

Upvotes: 0

Views: 52

Answers (1)

huon
huon

Reputation: 102086

This will remove everything up to the next /.

someXpath.replaceAll("/preceding-sibling::[^/]*","")

Upvotes: 1

Related Questions