-5
<project name="kernel/lk" path="bootable/bootloader/lk" revision="e48c9314142c2ae93619ccd14aba2bc975165ffd"/>
<Project name="device/google/contexthub" revision="c453c8b8fb25fb8e1c59e8288331a70dbff44061" />

I have above two lines in a file. I need to get the path and revision , If path is not available in the line it has to get the name and revision as output and save in a file

Expected output :

name="kernel/lk" , revision="e48c9314142c2ae93619ccd14aba2bc975165ffd"
path="device/google/contexthub" , revision="c453c8b8fb25fb8e1c59e8288331a70dbff44061"

It will be great helpful,if someone gives me the code snippet.

Gerhard
  • 22,678
  • 7
  • 27
  • 43
  • 2
    Are you expecting us to write this for you? Not showing any of your attempts and where you failed? – Gerhard Jan 16 '18 at 13:47
  • 3
    This looks like `xml`. Is it? If so, then the tool for the job is `xpath` not `regex`. And even if not - don't try and execute conditionals in regex. Use the parent scripting language (e.g. perl) – Sobrique Jan 16 '18 at 13:58
  • [H̸̡̪̯ͨ͊̽̅̾̎Ȩ̬̩̾͛ͪ̈́̀́͘ ̶̧̨̱̹̭̯ͧ̾ͬC̷̙̲̝͖ͭ̏ͥͮ͟Oͮ͏̮̪̝͍M̲̖͊̒ͪͩͬ̚̚͜Ȇ̴̟̟͙̞ͩ͌͝S̨̥̫͎̭ͯ̿̔̀ͅ](https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags) - use a parser – ctwheels Jan 16 '18 at 14:26
  • 1
    What have you tried? What problems are you having? Please show us your code. If you don't have code, then perhaps Stack Overflow isn't the best place for your question. (Also, please don't parse XML with regexes.) – Dave Cross Jan 16 '18 at 15:32
  • 3
    Why do people who can't write a parser insist on writing one themselves instead of using an existing one!? Use XML::LibXML!!! – ikegami Jan 16 '18 at 16:21

1 Answers1

-1

if ($row =~ m/name="(.+?)"\spath="(.+?)"\srevision="(.+?)"/g) { print "$1 $3\n";test }enter code here elsif ($row =~ m/name="(.+?)"\srevision="(.+?)"/g) {test print "$1 $2\n"; } }test