..." />
Xyz'a\\'bc\\d'123", "x = 'My string ends with with a backslash\\\\';" ) as $subject) { preg_match($pattern, $subject, $matches); echo $subject , ' => ', $matches0, "\n\n"; } prints => ' we\'re ready now. ' => " we\"re ready now. " xyz'a\'bc\d'123 => 'a\'bc\d' x = 'My string ends with with a backslash\\'; => 'My string ends with with a backslash.
Voting up because you provided test cases. – the. Jxc Jun 29 '09 at 21:42.
Here's my solution with test cases: /. *? '((?:\\\\|\\'|^')*+)'/ And my (Perl, but I don't use any Perl-specific features I don't think) proof: use strict; use warnings; my %tests = (); $tests{'Case 1'} = *?'((?:\\\\|\\'|^')*+)'/) { print " ... '$1'\n"; } else { print " ... NO MATCH\n"; } } Running this shows: $ perl a.
Pl Case 1... ... 'My string' Case 2... ... 'My string has it\'s challenges' Case 3... ... 'My string ends with a backslash\\' Note that the initial wildcard at the start needs to be non-greedy. Then I use non-backtracking matches to gobble up \\ and \' and then anything else that is not a standalone quote character. I think this one probably mimics the compiler's built-in approach, which should make it pretty bullet-proof.
. *'(^'\\|\\. )*'.
*/ The parenthesized portion looks for non-apostrophes/backslashes and backslash-escaped characters. If only certain characters can be escaped change the \\. To \\'\\a-z, or whatever.
Very nearly, but that doesn't handle the pathological case... 'My string ends with with a backslash\\' – the. Jxc Jun 29 '09 at 21:25 Thanks John! Fortunately for me, the cases I'm going to have to deal with can be restrained, and will never reach the problem that the.
Jxc describes. Very simple solution, of which I really should have thought. Again, thank you!
: ) – JMTyler Jun 29 '09 at 21:31.
Via negative look behind: / . *? ' #Match until ' ( .
*? #Lazy match & capture of everything after the first apostrophe ) (?* #Match remaining text.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.