To match a quoted string as in my example, using Perl. ($x)=$line=~m/((?:'[^']*')+)/;
What makes this "work" is the + at the end of the ) of the (?: ). That makes the regexp look back at the start. If there is a second ' mark, it continues to scan. What I don't have the the "recursive" use of ( ) since I need to know the "depth of nesting". On Fri, Jul 5, 2013 at 9:44 AM, Elardus Engelbrecht <[email protected]> wrote: > John McKown wrote: > >>One that always makes me sweat is matching the contents inside ' marks, where >>a single ' is encoded as two ' marks next to each other within the outer ' >>marks. The same matching contents within parentheses where subparameters >>within parentheses are permitted. E.g. 'This isn''t quite right!' or >>(a,b,(c,d),e). > > Hmmm, now I got a memory check from your nasty remark! Bang! Reboot! ;-D > > Curiousity question: years ago I asked that question to a professor, but got > no answer. > Question: Can you replace those two quotes (outer and inner) with something > not related to each other and then retry the parse? > > Something like this: 'This isn~}t quite right!' just temporarily change for > parse. > > Alternatively there are two types of quotes: > ' (single character with single mark) > " (single character with double marks) > > Can you alternate between them and do your reg parse? > Like this: "This isn''t quite right!" > > (Note: One character left of The. Two characters between N an T. One > character next to exclamation character.) > > Just curious if you don't mind please. > > Groete / Greetings > Elardus Engelbrecht > > ---------------------------------------------------------------------- > For IBM-MAIN subscribe / signoff / archive access instructions, > send email to [email protected] with the message: INFO IBM-MAIN -- This is a test of the Emergency Broadcast System. If this had been an actual emergency, do you really think we'd stick around to tell you? Maranatha! <>< John McKown ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN
