0

I'm printing user song from my server like this:

<id>0000</id>
<song>Song 1</song>
<id>1111</id>
<song>Song 2</song>
<id>2222</id>
<song>Song 3</song>

I'm using regex to get all IDs into array with this pattern <id>(.*?)<\/id> but it's only selecting first ID (<id>0000</id>). Why it isn't selecting all IDs?

NSArray *song_id = [user matchWithRegex:@"<id>(.*?)<\/id>"];
user47823
  • 49
  • 1
  • 6

1 Answers1

1

Multiline approach with regular expressions:

^<id>(.+?)</id>$

But mandatory: use a parser instead.
See a demo on regex101.com.

Community
  • 1
  • 1
Jan
  • 42,290
  • 8
  • 54
  • 79