Got more questions? Find advice on: ASP | SQL | XML | Windows
in Search
Welcome to RegexAdvice Sign in | Join | Help

replace characters(seperators) within quotes

Last post 11-18-2010, 11:15 AM by speedster. 0 replies.
Sort Posts: Previous Next
  •  11-18-2010, 11:15 AM 73979

    replace characters(seperators) within quotes

     

    Hi I am debugging a pear package (File_CSV).

    At some point for a line all seperators within quotes need to be replaced with an underscore.

    The code that is being used right now:

    $orgLine = '1001;"test1";"semicolon ; in this string" ';

    $line = preg_replace("|^[^"\';]*;*(["\'][^"\']*["\'])|sm", '_', $orgLine);

    It is faulty.

    I guess the tricky part is within quotes is valid only if lefthand quote-position= oneven and righthand quote-position=even , otherwise the semicolon is used as a seperator.

     

    Anyone any suggestiones?

     

     

View as RSS news feed in XML