Perl Pattern

Get help with installation and running here.

Moderators: DataMystic Support, Moderators

RogerW37
Posts: 4
Joined: Fri Mar 05, 2004 5:35 am

Perl Pattern

Postby RogerW37 » Fri Mar 05, 2004 5:48 am

I'm making this much harder than it should be...

I have one file, with multiple lines such as:

2800 Western Parkway, Ronald J. Prater and Gary M. and Margaret Boswell to Hugh P. and Jennifer Bosley for $118,000.
423 Tampa Drive, Kevin D. and Tabitha Hooker to Angela Baird for $67,000.
5035 Graham Lane, Helen L. Tipton to Charles L. Lamar for $47,550.

I need to convert this to:

"118000","Hugh P. and Jennifer Bosley","2800 Western Parkway"
"67000","Angela Baird","423 Tampa Drive"
"47550","Charles L. Lamar","5035 Graham Lane"

I plan to import that converted infomation into Excel.

I'm using TextPipe Standard and here's what I have so far (that isn't working)...
(\d+.*)(,)(\w+.*to)(\w+.*)(for)(\$\d)

I'm certainly open to suggestions as I've been working on this for awhile and I know I'm making it hard than it should be.

Thanks in advance for any insight.

Roger

User avatar
DataMystic Support
Site Admin
Posts: 2136
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Postby DataMystic Support » Fri Mar 05, 2004 7:57 am

Try

(\d+.*)(,)(\w+.*to)(\w+.*)(for)([^\d]*\$\d+?)

You were ignoring the spaces between 'for' and the dollar value.
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments

RogerW37
Posts: 4
Joined: Fri Mar 05, 2004 5:35 am

Postby RogerW37 » Fri Mar 05, 2004 12:33 pm

Wow! Thanks Simon for the prompt reply.

Here's what I did...
1. I copied your code verbatim into the "Find pattern (perl-style)" box.
2. Put "$6","$4","$1" into the "Replace with" box.
3. No check marks below the "Replace with" box.
4. I used the example code I listed above in the "Trial input" box.
5. Clicked "Trial run."

It simply displayed the same example code without any adjustments.

I put a check mark in the "Prompt on replace" to see if it was finding matches, and as I expected, it never prompted me about any replacements.

I tried a couple of other things as well that never moved me forward with a workable solution.

I would appreciate any additional ideas anyone has. I will work on this more tomorrow.

Thanks again!

Roger

User avatar
DataMystic Support
Site Admin
Posts: 2136
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Postby DataMystic Support » Fri Mar 05, 2004 1:42 pm

Remove the text in the replace box.

Then remove most of the pattern from the search box, verify it gets found, and then gradually add bits back until you find where it is not matching.
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments

RogerW37
Posts: 4
Joined: Fri Mar 05, 2004 5:35 am

Postby RogerW37 » Sat Mar 06, 2004 6:02 am

(\w+.*to)

This is the problem spot as it is looking for any "word" character with the usage of \w and there are periods (.) in this section such as:

Ronald J. Prater and Gary M. and Margaret Boswell to

I've tried a few things, but nothing seems to help me get around this.

Ideas?

Thanks,
Roger

User avatar
DataMystic Support
Site Admin
Posts: 2136
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Postby DataMystic Support » Sat Mar 06, 2004 7:27 am

Try

([\w\.]+.*to)

add any other chartacters you need inside the [..]
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments

RogerW37
Posts: 4
Joined: Fri Mar 05, 2004 5:35 am

Postby RogerW37 » Wed Mar 10, 2004 2:38 am

Thank you Simon! :D It worked!

(\d+.*)(,)([\w\.\ ]+.* to )([\w\.\ ]+.*)( for )([\d]*\$\d+?)

Thanks again!

Roger


Return to “TextPipe Tips and Tricks, Questions and Support”

Who is online

Users browsing this forum: Baidu [Spider] and 2 guests