Regex question ?

Posted on 2007-07-22
Medium Priority
Last Modified: 2008-07-03
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 & _

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

User ID/1

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

Thanks very much.
Question by:phpdotnet

Accepted Solution

punkstar earned 2000 total points
ID: 19543060
$subject = 'For $i = 1 To $User[0][0] Step 1
                  "User ID: " & $User[$i][1] & @CRLF & _
                  "Username: " & $User[$i][2] & @CRLF & _
preg_match_all('/(.*): " & \\$User\\[\\$i\\]\\[([\\d]*)\\]/', $subject, $result);

Is that what you're looking for? If its not, can you give a larger example of what your $subject data looks like.

Author Comment

ID: 19543949
Nah, that's what I need. Thanks for your answer :)

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This holiday season, we’re giving away the gift of knowledge—tech knowledge, that is. Keep reading to see what hacks, tips, and trends we have wrapped and waiting for you under the tree.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month14 days, 13 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question