Regex question ?

If I have some text like this :

For $i = 1 To $User[0][0] Step 1
                  "User ID: " & $User[$i][1] & @CRLF & _
                  "Username: " & $User[$i][2] & @CRLF & _
Next

Can anyone please show me an example of how to use regex to print :

User ID/1
Username/2

( where the number after the / is the number in the bracket )

Thanks very much.
phpdotnetAsked:
Who is Participating?
 
punkstarConnect With a Mentor Commented:
<?php
$subject = 'For $i = 1 To $User[0][0] Step 1
                  "User ID: " & $User[$i][1] & @CRLF & _
                  "Username: " & $User[$i][2] & @CRLF & _
Next';
preg_match_all('/(.*): " & \\$User\\[\\$i\\]\\[([\\d]*)\\]/', $subject, $result);
print_r($result);
?>

Is that what you're looking for? If its not, can you give a larger example of what your $subject data looks like.
0
 
phpdotnetAuthor Commented:
Nah, that's what I need. Thanks for your answer :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.