0

I am using Java Scanner class to delimit a String

Here is my string

locations:[{linkId:21737516,latLng:{lat:12.9219,lng:77.56022},type:s},

{linkId:21741609,latLng:{lat:12.921509,lng:77.49382},type:s},

{linkId:18632091,latLng:{lat:12.904157,lng:77.470489},type:v},

{linkId:76684742,latLng:{lat:12.88959,lng:77.45314},type:s}

I am using

s.useDelimiter("linkId");

I remove linkid but how can remove linkId:Integer from the above set of String which has diffrent integer??

please help me

4
  • you mean you need integer part of linkid? Commented Dec 31, 2014 at 7:29
  • Please show us sample input and expected output.. Commented Dec 31, 2014 at 7:30
  • Perhaps you describe what really needs to be done: skip linkId:18632091,`but then continue to read using a Scanner? You don't "delimit" a string using a scanner, you parse =(= extract its substrings). Commented Dec 31, 2014 at 7:31
  • Hey here is my i/p locations:[{:21737516,latLng:{lat:12.9219,lng:77.56022},type:s}, {:21741609,latLng:{lat:12.921509,lng:77.49382},type:s}, From this I want to remove :21737516, & :21741609, along with comma How should I do that please help Commented Dec 31, 2014 at 9:44

1 Answer 1

2

Try using a simple regex:

s.useDelimiter("linkId:\\d+");

\\d+ will include the digits after the :

Sign up to request clarification or add additional context in comments.

1 Comment

i voted u up but why not using replace it with "" or something like that?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.