Page 1 of 1
Find&Replace,Beginning&End of Text using Wild Card
Posted: Thu Feb 24, 2011 8:27 pm
by jmca2000
Hi, I tried finding an example of this on the forum but could not find it.
How do you Find the following using a wild card:
whiteLineDown
&& orangeLineUp
&& yellowLineDown
&& cyanLineDown
&& blackLineDown
&& dodBlueLineDown
&& blueLineDown
&& greenLineDown
&& redLineDown
AND Replace it with the following:
Print("&& whiteLineDown");
Print("&& orangeLineUp");
Print("&& yellowLineDown");
Print("&& cyanLineDown");
Print("&& blackLineDown");
Print("&& dodBlueLineDown");
Print("&& blueLineDown");
Print("&& greenLineDown");
Print("&& redLineDown");
Thank You Very Much For Your Support in Advance. 
Posted: Thu Feb 24, 2011 11:44 pm
by ben_josephs
Does this supersede your earlier question? This one is much easier:
Use "Posix" regular expression syntax:
Configure | Preferences | Editor
[X] Use POSIX regular expression syntax
Search | Replace... (
<F8>):
Find what: ^&* *(.+)
Replace with: Print("\&\& \1");
[X] Regular expression
Replace All
Posted: Fri Feb 25, 2011 2:04 am
by jmca2000
Hi Ben, Thanks for your Help. I used the code you gave me but I got the Following response: "Cannot find regular expression:" ^&* *(.+)
I don't know why it did not work? I only used one space and that was between the * *. Also to answer your question, it did not supersede my other quesion. I also need to be able to Convert and Transpose Text to an Additional Location. Thanks Again for your support.
Posted: Fri Feb 25, 2011 10:58 am
by ben_josephs
Are you using "Posix" regular expression syntax?
Has a spurious space been introduced at the end of your regex?
Are there leading spaces in your source that aren't in your posting?
Posted: Fri Feb 25, 2011 3:23 pm
by jmca2000
Hi Ben, In my C# compiler it sort of works but does not work in TextPad

.
I get the Following result from the compiler:
Print("whiteLineDownwhiteLineDown whiteLineDown");
Print("&& orangeLineUp&& orangeLineUp orangeLineUp");
Print("&& yellowLineDown&& yellowLineDown yellowLineDown");
Print("&& cyanLineDown&& cyanLineDown cyanLineDown");
Print("&& blackLineDown&& blackLineDown blackLineDown");
Print("&& dodBlueLineDown&& dodBlueLineDown dodBlueLineDown");
Print("&& blueLineDown&& blueLineDown blueLineDown");
Print("&& greenLineDown&& greenLineDown greenLineDown");
Print("&& redLineDown&& redLineDown redLineDown");

Posted: Fri Feb 25, 2011 3:34 pm
by ben_josephs
I can assure you it does work in TextPad.
What are the answers to the questions I asked?
I presume you mean it works as you describe in the IDE of your C# compiler. That is not relevant here: your IDE is not using TextPad's regex engine.
Posted: Fri Feb 25, 2011 3:48 pm
by jmca2000
Are you using "Posix" regular expression syntax?
I check the box that says Regular expression.
Has a spurious space been introduced at the end of your regex?
No.
Are there leading spaces in your source that aren't in your posting?
No, I Cleaned the code up took all spaces and tabs out.
Thanks.
Posted: Fri Feb 25, 2011 3:55 pm
by ben_josephs
Please read my original reply again and follow its suggestions precisely.
Posted: Fri Feb 25, 2011 4:23 pm
by jmca2000
Hi Ben,
Please forgive my lack of knowledge of Regular expressions, I NEVER heard of this until about 2 days ago. I wish I would have known about this weeks ago, I can't tell you the amount of time this would have saved me.
I guess I figured out what you meant by Use POSIX (what ever that means)

. I went to Preferences > Editor >and checked the box that says "Use POSIX regular expression syntax". It WORKS, Thanks for your patience.
What would I replace in the code to Convert 'whiteLineDown' to 'Print("&& whiteLineDown"); ' , that is the only one that does not start with &&
Also Could you
PLEASE,
PLEASE help me with the other Post otherwise I'm going to have to make 1000's of manual changes to my code
THANKs so Much in Advance.

Posted: Fri Feb 25, 2011 5:00 pm
by ben_josephs
My suggestion does convert
whiteLineDown
to
Print("&& whiteLineDown");
The regex is contructed in an odd way to ensure it does do this. It's a bit tricky with TextPad's weak and slightly perverse old regex engine.
Posted: Fri Feb 25, 2011 5:10 pm
by jmca2000
I'm Sorry Ben I meant 'whiteLineDown' to 'Print("whiteLineDown");'
Thanks.
Posted: Fri Feb 25, 2011 6:01 pm
by ben_josephs
That is not what you asked for originally.
Find what: .+
Replace with: Print("\0");
[X] Regular expression
Replace All
Posted: Fri Feb 25, 2011 6:45 pm
by jmca2000
I Know, Thanks for your continued Help.
I Hope it's still possible you could help me out with the other modified Post?
Thanks Again Joe.