I have a text file which I want to convert to a CSV.
All I would need to do is to convert <space> to comma to do this except for one complication, the file includes text in quotes and the spaces should not be removed from text in quotes.
Is there a regular expression which will tell WildEdit to replace all spaces with commas except if those spaces are within quotes?
excluding text in quotes
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
thank you, I think I understand that
Yes! Wow! I am impressed with both the tool and your understanding of it.ben_josephs wrote:Here's one way to do it, using conditional expressions:Find what: ( )|("[^"]*")
Replace with: ?1():?2($2)
[X] Regular expression
[X] Replacement format
If I understand your suggestion correctly (and I probably don't!) to replace the spaces outside quotes with a comma I should say:
Find what: ( )|("[^"]*")
Replace with: ?1(,):?2($2)
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
brackets? yes please!
I think I'll keep the brackets, this regular expression business has my brain at the very edge of its abilities and dispensing with the brackets might just push me over the edge!ben_josephs wrote:Yes. Sorry, my mistake.
You can write the replacement expression equivalently as
?1,:?2$2
which has the virtue of being even more obscure. :-)
I brilliantly (!) figured out that the equivalent Find expression in TextPad is: \( \)\|\("[^"]*"\)
But I cannot figure out the TextPad equivalent of the replacement expression: ?1():?2($2)
Is there one?
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
Use Posix regular expression syntax:
No, there is no equivalent in TextPad to WildEdit's fancy replacement expressions, or to many of its fancy regular expressions. (Note that a replacement expression is not a regular expression.) The regular expression engine used by TextPad is rather old and tired; WildEdit uses the Boost engine, which is far more powerful.
Then you can use same regular expression as you did in WildEdit.Configure | Preferences | Editor
[X] Use POSIX regular expression syntax
No, there is no equivalent in TextPad to WildEdit's fancy replacement expressions, or to many of its fancy regular expressions. (Note that a replacement expression is not a regular expression.) The regular expression engine used by TextPad is rather old and tired; WildEdit uses the Boost engine, which is far more powerful.
Thanks for all the help.ben_josephs wrote:No, there is no equivalent in TextPad to WildEdit's fancy replacement expressions, or to many of its fancy regular expressions. (Note that a replacement expression is not a regular expression.) The regular expression engine used by TextPad is rather old and tired; WildEdit uses the Boost engine, which is far more powerful.
Is there going to be a new improved version of TextPad with Boost someday?