-1

i have string, which has the value like

"urls":[
        {
         "url":"https:\/\/t.co\/OjiDUThEvK",
         "expanded_url":"http:(escape sequence slash)/(escape sequence slash)/fb.me\/7Wnh0hMLL",
         "display_url":"fb.me(escape sequence slash)/7Wnh0hMLL",
         "indices":[48,71]}],
         "user_mentions":[],
         "symbols":[]
        }
      ] 

i need to capture only "expanded url" i tried the following regex:

"expanded_url"\:\"http\:\\\/\\\/(.*?)\"

this gave a result :

"fb.me(escape sequence slash)/7Wnh0hMLL" 

but i want to exclude the escape sequence slash in the URL, is it possible to achieve the same, kindly let me know the changes to me made to the regex

semirturgay
  • 4,151
  • 3
  • 30
  • 50
  • 3
    Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems. Why don't you deserialize your json to get the url? – David Brabant Feb 16 '16 at 07:21

1 Answers1

0

I'm not 100% sure if this is what you're after. Can you post the raw input without the "(escape sequence slash)" part I'm assuming that this is actually / in the text you're matching against.

match:

\"expanded_url\":\"http:\\\/\\\/([^\\]*)\\\/([^\\"]*)\"

replace with:

$1/$2
Ed'
  • 397
  • 2
  • 7
  • Your assumption is correct, i am not able to put / since stack over flow is ignoring it. The above regex give two match groups 1. fb.me 2. 4sQlKWaQZ but i am expecting only one capture group with output fb.me/4sQlKWaQZ – shriram bharath Feb 16 '16 at 08:22
  • There isn't a way to ignore the `\ ` from the `\/ ` in the middle of the group. See: http://stackoverflow.com/questions/277547/regular-expression-to-skip-character-in-capture-group Basically you will need to have 2 groups and concatenate them later. – Ed' Feb 16 '16 at 09:41