Regex expert needed

From: Alan Chandler (alan_at_chandlerfamily.org.uk)
Date: 04/30/05

  • Next message: Sven Arvidsson: "Re: DAEWOO dw-8000P adsl modem/nic driver?"
    To: debian-user@lists.debian.org
    Date: Sat, 30 Apr 2005 21:42:55 +0100
    
    

    I am using PHP and I am trying to parse a string into substrings delimited by
    a single character. In some instances this is a ',' in others it will be '='.

    I think the php function preg_split is the one to use, but I need find the
    right regular expression to match the delimeter character. Not being an
    expert and seeing its just not an obvious single character (see below) it has
    confused me completely.

    Unfortunately a subset of the substrings themselves may have ',' or '=' signs
    in them, although each string in this subset will itself have had the
    addslashes() function performed on it to escape internal quote characters and
    then completely surrounded in a pair of single quote characters.

    In otherwords my regular expression does not want to match a ',' (or in the
    other case a '=') if it is inside an unescaped quote.

    So can any regular expression experts out there help me define the right one
    to match the criteria I have described.

    TIA

    -- 
    Alan Chandler
    http://www.chandlerfamily.org.uk
    -- 
    To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org 
    with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
    

  • Next message: Sven Arvidsson: "Re: DAEWOO dw-8000P adsl modem/nic driver?"

    Relevant Pages

    • Re: replace single slash with double slash
      ... Parse error: parse error, unexpected T_VARIABLE in c:\Inetpub\wwwroot ... The backslash character is the escape character. ... Where is your string coming from? ... php does it's own converting of the slashes. ...
      (comp.lang.php)
    • Re: [PHP] php seems to be inconsistent in its handling of backslashes ... maybe?
      ... some other non-special character, by just pretending you knew what ... Not that I can deny Richard's infinite knowledge of PHP (and it ... hex and octal codes) just turns into a plain old \ ... string, personally, but apparently I'm in the minority. ...
      (php.general)
    • Re: How does PHP store strings?
      ... PHP does in fact store strings with a null termination, ... The individual character literals can be ... There is in fact a null terminator. ... or access out of the bounds of the string. ...
      (php.general)
    • Re: [PHP] case and accent - insensitive regular expression?
      ... $string = strtr; ... so you replace every occurence of every accent variation with all the ... It matches any character based on the latin 'a' that is not ...
      (php.general)
    • Re: Find and Replace - Changing 1st # only
      ... To enter the UDF, ... Match the character ?$? ... Match a single character that is a ?whitespace character? ... Function ReRepl(str As String, sPat As String, _ ...
      (microsoft.public.excel.misc)