Vladimir
Vladimir

Reputation: 13173

Exclusion in regexp

I have a strings like:

{ "_id" : ObjectId( "4ebb9544e4b097b7e6617e1c" ), "_class" :

I need a strings like:

{ "_id" : "4ebb9544e4b097b7e6617e1c", "_class" :

How to make this conversion in java?

Upvotes: 0

Views: 78

Answers (1)

ruakh
ruakh

Reputation: 183602

If you really know the exact form of the string, and the object-ID will always be hex like that, you can just do:

s = s.replaceAll("ObjectId\\( ([^)]+) \\)", "$1");

Upvotes: 1

Related Questions