Replacing Regular Expressions

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
dforrest
Posts: 44
Joined: Mon Jan 19, 2004 11:19 pm
Location: St. Vincent and the Grenadines

Replacing Regular Expressions

Post by dforrest »

I have until recently been able to replace strings based on regular expressions in multiple documents but cannot now do this.

Can anyone assist?

I am trying to replace:
Coupling (\n Type ( chain )\n Spring (\n Stiffness ( 1e6N/m 5e6N/m )\n Damping ( 1e6N/m/s 1e6N/m/s )\n Break ( 5.1e7N 5.1e7N )\n r0 ( 20cm 30cm )\n )\n Velocity ( 0.1m/s )\n )\n Coupling (\n Type ( chain )\n Spring (\n Stiffness ( 1e6N/m 5e6N/m )\n Damping ( 1e6N/m/s 1e6N/m/s )\n Break ( 5.1e7N 5.1e7N )\n r0 ( 20cm 30cm )\n )\n Velocity ( -0.1m/s )\n )\n Buffers (\n Spring (\n Stiffness ( 1e6N/m 5e6N/m )\n Damping ( 1e6N/m/s 1e6N/m/s )\n r0 ( 0m 1e9 )\n )\n Centre ( 0.5 )\n Radius ( 1 )\n Angle ( 0.5deg )\n )\n
With:
\n Coupling ( \n Type ( Chain ) \n Spring ( \n Stiffness ( 1e6N/m 5e6N/m ) \n Damping ( 1e6N/m/s 5e6N/m/s ) \n Break ( 1e8N 1e8N ) \n r0 ( 20cm 40cm ) \n ) \n Velocity ( 0.1m/s ) \n ) \n\n Coupling ( \n Type ( Chain ) \n Spring ( \n Stiffness ( 1e6N/m 5e6N/m ) \n Damping ( 1e6N/m/s 5e6N/m/s ) \n Break ( 1e8N 1e8N ) \n r0 ( 20cm 40cm ) \n ) \n Velocity ( -0.1m/s ) \n )\n\n
And get the error message "Cannot match regular expression".
ben_josephs
Posts: 2459
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Have you changed the version of TextPad you're using? If you're using version 6 or earlier, have you changed the style of regex you're using?
User avatar
Drxenos
Posts: 210
Joined: Mon Jul 07, 2003 8:38 pm

Post by Drxenos »

Instead of trying to debug such a large expression. Start with a small one, make sure it matches, and incrementally build up.
ben_josephs
Posts: 2459
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Very good advice.
dforrest
Posts: 44
Joined: Mon Jan 19, 2004 11:19 pm
Location: St. Vincent and the Grenadines

Post by dforrest »

ben_josephs wrote:Have you changed the version of TextPad you're using? If you're using version 6 or earlier, have you changed the style of regex you're using?
Yes I have recently upgraded to the latest version of TextPad. Sorry, I do not understand about regex.

.
Last edited by dforrest on Tue Jun 25, 2013 7:25 pm, edited 1 time in total.
dforrest
Posts: 44
Joined: Mon Jan 19, 2004 11:19 pm
Location: St. Vincent and the Grenadines

Post by dforrest »

Drxenos wrote:Instead of trying to debug such a large expression. Start with a small one, make sure it matches, and incrementally build up.
The fist expression is a "copy" of an actual section of the document. The second expression is a "copy" of a section of another document.
ben_josephs
Posts: 2459
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

You are asking us to guess what you are trying to do.

Do the "\n"s represent newlines or are they literal "\n"s?
Do you want an extra "\n" (literal or otherwise) introduced between Coupling sections?
Do you want all Buffer sections deleted?
Do you want the Type "chain" always to have its initial capitalised?
What is the rule for adjusting the Damping value? ("1e6N/m/s 1e6N/m/s" appears to change to "1e6N/m/s 5e6N/m/s".)
What is the rule for adjusting the Break value? ("5.1e7N 5.1e7N" appears to change to "1e8N 1e8N".)
What is the rule for adjusting the r0 value? ("20cm 30cm" appears to change to "20cm 40cm".)
Etc...
User avatar
Drxenos
Posts: 210
Joined: Mon Jul 07, 2003 8:38 pm

Post by Drxenos »

dforrest wrote:
Drxenos wrote:Instead of trying to debug such a large expression. Start with a small one, make sure it matches, and incrementally build up.
The fist expression is a "copy" of an actual section of the document. The second expression is a "copy" of a section of another document.
How does that negate the fact it is much too large and complex for us to easily tell you why it doesn't work the way you want it to?
dforrest
Posts: 44
Joined: Mon Jan 19, 2004 11:19 pm
Location: St. Vincent and the Grenadines

Post by dforrest »

In the past I have cheched "Regular expression" in the "Replace" dialogue box and copied the block I want to replace and pasted this into the "Find what"" box.

I have similarly copied and pasted the block of text I want it reppaced with into the "Replace with:" box (I copy this from onother document).

I the check "All documents" and choose "Replace All" and all occurances of the first block are replaced by the second block.

This does not appear to work with the latest version of TextPad.
ben_josephs
Posts: 2459
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

That couldn't have worked with your example in any version of TextPad, because of the backslashes and, depending on version and settings, the parentheses.

You still haven't answered the points raised by Drxenos and me, and you are still expecting us to guess what you want.

If you want help you will have to put as least as much effort into your questions as you expect others to put into their answers.
dforrest
Posts: 44
Joined: Mon Jan 19, 2004 11:19 pm
Location: St. Vincent and the Grenadines

Post by dforrest »

Ben, I cannot answer you points becuase I do not know the answers. I have previously been able to highlight a block of text, with "Regular expression" chosen, and replace it in all open documents with another block of text chosen. For some reason, I cannot now do this.

David
ben_josephs
Posts: 2459
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

If you want to replace literal text with literal text, why are you selecting Regular expression? Try deselecting it.
dforrest
Posts: 44
Joined: Mon Jan 19, 2004 11:19 pm
Location: St. Vincent and the Grenadines

Post by dforrest »

ben_josephs wrote:If you want to replace literal text with literal text, why are you selecting Regular expression? Try deselecting it.
When I do that I get the message "Cannot find literal text:".
dforrest
Posts: 44
Joined: Mon Jan 19, 2004 11:19 pm
Location: St. Vincent and the Grenadines

Post by dforrest »

This thread appers to explain why I am having the problem:

http://forums.textpad.com/viewtopic.php?t=12384

I have successfully made the change (to about 150 documents) by using WildEdit.

.
Post Reply