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

Regular expression help

  • 13-06-2007 4:04pm
    #1
    Registered Users, Registered Users 2 Posts: 1,653 ✭✭✭


    Hi - Can someone please give me a regular expression for the following:

    Matches strings which start with

    My name is Mark

    but do not include

    and I live in Dublin


Comments

  • Registered Users, Registered Users 2 Posts: 950 ✭✭✭jessy


    what language are you using? have you made an attempt at this already?


  • Closed Accounts Posts: 97 ✭✭koloughlin


    Here's a perl regex that I think does this
    /^My name is Mark(?!.*and I live in Dublin)/
    


  • Registered Users, Registered Users 2 Posts: 1,653 ✭✭✭m_stan


    I'm actually just doing a big find and replace in Dreamweaver on an XML file.

    What I ideally need to do is replace any of the following

    My name is Mark and I am Irish and have blue eyes
    My name is Mark and I am male and have size 10 feet
    My name is Mark and I am tired and want to sleep

    with

    My name is Mark and I live in Dublin (followed by the rest of the original string after the 'Mark')

    Does that make sense ? Any help very much appreciated. This file is big with over 3000 matches to replace so I want to avoid doing this by hand.


  • Closed Accounts Posts: 97 ✭✭koloughlin


    Ok, then this will probably do that in perl
    #!/usr/bin/perl -w
    
    while(<>) {
       s/^My name is Mark(?!.*and I live in Dublin)/My name is Mark and I live in Dublin/; {
          print;
       }
    }
    


  • Registered Users, Registered Users 2 Posts: 950 ✭✭✭jessy


    so your not trying to develope an application or anything, you just want to save some time in updating an xml file which cantains a large amount of text? a once off update?


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 1,653 ✭✭✭m_stan


    Gottit ! Thanks for your help. Very relieved not to have to do all this manually !!!


Advertisement