Any Regex Gurus -

92 views
Skip to first unread message

Prashant Maheshwari

unread,
Jul 11, 2022, 1:13:27 PM7/11/22
to BBEdit Talk
I can extract all text between good and quotes by search good.*"


How to modify to extract between two quotes starting from good
good for me",yo





hello how are we doing my brother "good for me",yo","what you say?"



David G Wagner

unread,
Jul 11, 2022, 3:29:27 PM7/11/22
to BBEdit Talk
good[^"]*"[^"]* Will give you:

good for me",yo"
--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/51853ddb-e1ad-4959-8b3a-0406dd7934cen%40googlegroups.com.

eu...@gmx.de

unread,
Jul 12, 2022, 10:02:56 AM7/12/22
to bbe...@googlegroups.com
Try this:
Search pattern:  "\b(.*)(")(.*)\b
Replace pattern:  "\1\3

This changes  "good for me",yo“ to  "good for me,yo“

And then:
Search pattern:  (\w),(\w)
Replace pattern:  \1, \2

To change "good for me,yo“ to "good for me, yo“

Hope I understood your need.

Ulrich

Prashant Maheshwari

unread,
Jul 13, 2022, 6:45:37 AM7/13/22
to BBEdit Talk

Thank you both !!! 

I had completely forgotten negation [^ and word boundaries \b !

Prashant Maheshwari

unread,
Jul 13, 2022, 7:56:52 AM7/13/22
to BBEdit Talk

If you don't mind my followup questions 
good[^"]*"[^"]* Will give you:

This one reads 
1. Match good
2. Ignore first Inverted Comma after good ??--> I'm sure I'm wrong 
3. Match everything till Inverted Commas (greedy) -->???
4. Ignore Inverted Comma again 



On Tuesday, July 12, 2022 at 7:32:56 PM UTC+5:30 Ulrich Kapp wrote:

Kaveh

unread,
Jul 13, 2022, 12:24:22 PM7/13/22
to bbe...@googlegroups.com
Hi Prashant

A very good site to test regex is Regex101. For some reason it is showing engine error for me now. But it will give you a description of the regex. Here is how I would describe the pattern:
  • good – Match "good" exactly
  • [^"]* – 0 or more of any character except double quote (greedy)
  • " – Quote character
  • [^"]* – 0 or more of any character except double quote (greedy)
Does that help?



--
Kaveh Bazargan PhD
Director
Accelerating the Communication of Research
Reply all
Reply to author
Forward
0 new messages