Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

php regex

  • 02-05-2008 3:01pm
    #1
    Registered Users, Registered Users 2 Posts: 26,584 ✭✭✭✭


    hey guys,feel like i'm relying on you guys way too much.

    i'm coming from a perl/cgi background and moving to PHP for some projects,

    as you know regular expressions are used widely in perl/cgi and i became a somewhat expert at them but trying to replicate the same standards in php is proving quite taxing.

    i have an entry in a column in a database that's delimited by a tilde (~) an example line would be like so:

    yes~no~maybe~go~away~joe

    what i want to do is to split this so that i can store each value into a variable for further processing.
    in perl this was easy, all it was was to do this:

    if($str =~ /~(.+)~(.+)~(.+)~(.+)~(.+)~(.+)/ )
    {
    var1= $1;
    var2= $2;
    ...
    var6= $6;
    }

    as far as i was aware this was called grouping in perl but when i tried googling for the same functionality i can't find nothing, just regular match a simple pattern.

    anyone have any good web resources they'd like to share?


Comments

  • Registered Users, Registered Users 2 Posts: 3,428 ✭✭✭randombar


    explode would be the best one for this i reckon


  • Registered Users, Registered Users 2 Posts: 26,584 ✭✭✭✭Creamy Goodness


    ahhh you genius.

    i knew php.net had a similar documentation ala javadocs but it's impossible to search for functions when you don't know the names.

    thanks man.


  • Registered Users, Registered Users 2 Posts: 3,428 ✭✭✭randombar


    Ya de lads on here are brilliant for giving the names of functions!

    god bless boards!


  • Registered Users, Registered Users 2 Posts: 6,570 ✭✭✭daymobrew


    Cremo wrote: »
    i'm coming from a perl/cgi background and moving to PHP for some projects,
    As you know perl regex, you can use the Perl Compatible Regular Expression functions.
    Cremo wrote:
    i knew php.net had a similar documentation ala javadocs but it's impossible to search for functions when you don't know the names.
    Then I suggest looking at the category index.


Advertisement