You are here: PSPad forum > English discussion forum > Multi-Line Search Add-On

Multi-Line Search Add-On

Goto Page: PreviousFirst...2 3 4 5 6 7 8 9 10 11 12 ...LastNext

#61 Re: Multi-Line Search Testers Needed

Posted by: Replika | Date: 2007-07-09 20:09 | IP: IP Logged

I have a text like this:
abb
c

but if i search for a(.*)c, it does not found

Options: Reply | Quote | Up ^


#62 Re: Multi-Line Search Testers Needed

Posted by: andybridges | Date: 2007-07-10 08:11 | IP: IP Logged

Replika:
I have a text like this:
abb
c

but if i search for a(.*)c, it does not found

"." does not include line breaks

try:
a((.|\n)*)c

If you're ever unsure of reg ex syntax, try www.regular-expressions.info

Options: Reply | Quote | Up ^


#63 Re: Multi-Line Search Testers Needed

Posted by: Replika | Date: 2007-07-11 16:52 | IP: IP Logged

I just thought phReplace contains "Dot matches newline". Hope this is available in the future.

But how to replace with matched groups, it just returns pure text "$1" (or \\1, \1)

Edited 1 time(s). Last edit at 2007-07-11 16:52 by Replika.

Options: Reply | Quote | Up ^


#64 Re: Multi-Line Search Testers Needed

Posted by: vbr | Date: 2007-07-11 20:12 | IP: IP Logged

Replika:
But how to replace with matched groups, it just returns pure text "$1" (or \\1, \1)

Unfortunately, the backreferences don't seem to be supported in the current version (see #54).

Options: Reply | Quote | Up ^


#65 Re: Multi-Line Search Testers Needed

Posted by: vbr | Date: 2007-07-26 08:14 | IP: IP Logged

I'd like to thank phdesigner for the new version of his multiline replacement script and draw the attention of other users to this update:
the greatest improvement of the version 1.3.15 (17th July) is maybe the "replace all"; it is quite a bit faster and can be undone in one step (since 1.3 ...) but now it seems to handle newlines correctly. (the problem described in #52 seems to be fixed now).

There is also an announcement "Added ability to use $0 in Regular Expression replaces." but I haven't found out yet, how it works. Are there maybe any hints?

Options: Reply | Quote | Up ^


#66 Re: Multi-Line Search Testers Needed

Posted by: MrSpock | Date: 2007-07-26 10:26 | IP: IP Logged

Thanks vbr for pointing this out, and thanks phdesigner for this really awesome tool!

Options: Reply | Quote | Up ^


#67 Re: Multi-Line Search Testers Needed

Posted by: Stefan | Date: 2007-07-27 10:59 | IP: IP Logged

Maaany thanks phdesigner

(..and vbr too!
The $0 backreferences is announced since all 1.3.x versions
but i still don't know how it should work.
Normal would be
Search: (regex)
Replace: $1

I think it didn't work at all right now, see #54 grinning smiley )

.

--------------

Multiline search works fine:

<script(\s|\t|.|\r\n)*</script>

of course use ? for non.greedy like
<script(\s|\t|.|\r\n)*?</script>

.

----------
And be patient if phReplace does nothing
after starting the search ... it's still
at work... just wait some ten seconds.
Especially on big files or if you use an greedy RegEx grinning smiley
(@phReplaceDesigner:
phReplace needs an loop to look every 30sec if Cancel is pressed. Isn't it?)

Options: Reply | Quote | Up ^


#68 Re: Multi-Line Search Testers Needed

Posted by: phdesigner | Date: 2007-08-13 05:16 | IP: IP Logged

Hi,

Sorry I haven't been answering posts for a while, was a bit removed from society for the last few months.

It has already been pointed out version 1.3.15 is available for download, this version fixes the problem where phReplace truncates text following a 'Replace All' in a selection. What was happening was if the search and replace text were different lenghts, it wasn't adjusting the selection to accomodate the new length.

I'm aware of a couple of issues still exisitng:
1. phReplace doesn't run on Windows Vista.
2. Apparently there is a bug when using Replace All with word wrap enabled. I haven't been able to recreate this yet but am working on it.
3. There seems to be some confusion with replacing regular expression matches using $1, $2 etc.. This is probably because of my limited understanding of RE.

How it works now: For one it only works on Replace All, not a single Replace.
If you have an expression like '<(.*)>' and replace it with '<$1_Test>' then it should append _Test to the text within a tag.
From what I assume you need to use brackets to specify a match to use in the repalce all, if there are multiple bracket sets then use $1, $2 to reference them.

Example:
Text:
<Tag1>
<Tag2>
Value
</Tag2>
</Tag1>
Search: <(.*)>
Replace: <$1_Test>
Result:
<Tag1_Test>
<Tag2_Test>
Value
</Tag2_Test>
</Tag1_Test>

Hope this helps.

Options: Reply | Quote | Up ^


#69 Re: Multi-Line Search Testers Needed

Posted by: vbr | Date: 2007-08-15 19:20 | IP: IP Logged

phdesigner:
regular expression matches using $1, $2 etc..
...
For one it only works on Replace All, not a single Replace.
...

That was it! smiling smiley Apparently, I didn't try this feature in Replace All mode.
Are there maybe yet another differences in the implementation of the single replace and replace all?
Thanks for the explanation and for the new version.

Options: Reply | Quote | Up ^


#70 Re: Multi-Line Search Testers Needed

Posted by: Stefan | Date: 2007-09-03 16:46 | IP: IP Logged

I just have copied some text from a web page and paste it into PSPad.
But the list was paste as
*

Text
*

Text

*...

.

With phReplace i was able to search for "\*\r\n\r\n" and replace with"* "
and i have reformatted my text at easy as:
* Text
* Text
* Text
*....

Many thanks Paul !

Options: Reply | Quote | Up ^


Goto Page: PreviousFirst...2 3 4 5 6 7 8 9 10 11 12 ...LastNext





Editor PSPad - freeware editor, © 2001 - 2019 Jan Fiala, Hosted by Webhosting TOJEONO.CZ, design by WebDesign PAY & SOFT, code Petr Dvořák, Privacy policy and GDPR