 |
 | [resolved] regular expressions and new lines |  |
Joined: 07 Mar 2007 |
Posts: 44 |
Location: Lithuania |
|
 |
Posted: Tue Aug 07, 2007 7:20 am |
|
 |
 |
 |
 |
Hi dmitry,
lets say I have php file that looks like this:
<?php
/**
* @desc Something
* @author Laurynas Karvelis
* @author "made.By" - http://www.by.lt/
* @date 2007-01-03
*/
// the rest of content is code...
...
?> |
Now I wan't to replace with this one
So I hit Ctrl + R, set options "Regular Expressions", "Promt on replace".
Text to find: \*/
Replace with: *\r\n* $Id$\r\n*/
After replacing, I got such a line in code:
After closing and re-opening the php file, I get normal code representation (new lines are correct), but before closing the file, I thought I messed something up...
Hope you understand  .
Bye
|
|
 |
 | |  |
 |
 | |  |
 |
 | |  |
Veteran
Joined: 26 Dec 2006 |
Posts: 253 |
Location: Phoenix, AZ |
|
 |
Posted: Tue Aug 07, 2007 12:13 pm |
|
 |
 |
 |
 |
thunder-ltu wrote: | No it isn't, so you want to tell, that your product supports find/replace with regular expressions, you document it in your phped.chm help file and it's actually working, just you didn't finished such characters rendering at fly time, but it's not supported. Did I understand that right? |
I've not gotten as far as testing whether it sort-of-kind-of-works with the replacement text, as would appear in your example, but I can tell you that the IDE falls flat on its face and quietly fails if you try to *search* for multi-line text. Right now, I have to do about 60% of my searches in another text editor because of this. Admittedly, PhpED is far from the only editor to have this huge deficiency, but it's disappointing nonetheless.
(Interestingly, this seems to be more of a Windows issue. I've never run into a Mac editor that supported PCRE but not over multiple lines. Before using Windows, this sort of limitation would never have even occurred to me as being a realistic possibility. However, it's a very common limitation on Windows. I wonder if there's some issue with the Windows port of the PCRE library, or something like that. It sure is a big limitation, though, whatever its root cause.)
|
|
 |
 | |  |
 |
 | |  |
Veteran
Joined: 26 Dec 2006 |
Posts: 253 |
Location: Phoenix, AZ |
|
 |
Posted: Tue Aug 07, 2007 12:52 pm |
|
 |
 |
 |
 |
thunder-ltu wrote: | you can search multiline texts in phpEd |
I've not been able to get it to work. If I have this in a UNIX-format file:
a
b
c
d
e
f
g
and I search for "b\n\c\n", the IDE won't find it, and Dmitri has said it won't work.
Quote: | It's a headacke for me too... BTW, what editor do you use to search multiline texts? |
For simple stuff, I use TextPad. However, it only supports POSIX syntax, which is much more limited than PCRE syntax... but at least it works. For the heavy lifting--like when I'm refactoring code--I am forced to resort to BBEdit over on my Mac. I've yet to see any tool on any platform with search/replace functionality better than BBEdit's. (BBEdit costs money, but its free sibling TextWrangler sports the same core search/replace engine, just without so many bells and whistles wrapped around it.)
I've yet to find something on Windows that does what I want. I *think* UltraEdit would fit the bill (just looking at the features list), but that's not something my employer would buy for me....
I've been trying to think of a way to use PhpED's integration features to enable use of PHP's own preg_xxx() function set for searches in the editor, but I haven't found any real docs for the integration features, nor have I been able to spend much time trying to figure it out. But if someone else knows how to whip this up and share it, I'm sure it'd be highly prized in the community here.
|
|
 |
 | |  |
 |
 | |  |
Veteran
Joined: 26 Dec 2006 |
Posts: 253 |
Location: Phoenix, AZ |
|
 |
Posted: Wed Aug 08, 2007 3:54 pm |
|
 |
 |
 |
 |
Here's a question, then. Many languages, including C/C++ (with which I assume PhpED was written), represent an array in memory as if serialized into a simple byte vector. Assuming you can insert or maintain the appropriate line break sequence as the last element/character of each line, this should mean that the array representing the text data would in fact be stored in memory as a vector perfectly suited to passing into PCRE.
From my understanding of PCRE, it essentially just requires you to hand it the compiled pattern and a string of data, and tell it what characters to consider line breaks, and it goes to work. So passing in your array of data should, theoretically, require nothing more than a cast.
Is there something I'm missing here? Does your text representation include more than just the text itself? If so, could it be converted on-the-fly? I obviously don't know anything about PhpED's internal implementation, so I'm interested in whether this issue is one that can we can reasonably assume may be addressed in a near-future update, or if it's the sort of thing that would require a major rewrite to accomplish.
|
|
 |
 | |  |
 |
 | |  |
 |
 | |  |
 |
 | |  |
Veteran
Joined: 26 Dec 2006 |
Posts: 253 |
Location: Phoenix, AZ |
|
 |
Posted: Mon Aug 20, 2007 12:34 pm |
|
 |
 |
 |
 |
I'd like to have that option. Right now, I'm frequently forced to follow this series of steps:
1) Select all or some portion of my code.
2) Copy it to the clipboard.
3) Fire up another editor.
4) Paste.
5) Do the search-and-replace.
6) Select everything.
7) Quit the editor.
8) When it asks, tell the editor that I don't want to save changes.
9) Switch back to PhpED.
10) Paste.
Needless to say, all this takes *far* long than 0.3 seconds :-). And, I suspect that the vast majority of PHP files are no more than a few hundred lines, which means the operation should be faster than with nusoap.php (which, if I remember right, is quite a bit bigger than a few hundred lines). And if you're working on a selection, as I usually am, the search text may only be several to several dozen lines. In other words, the performance penalty will be small and very much worth it. And as hardware gets faster, the time will just go down, and hopefully, you will someday be able to work around the problem.
|
|
 |
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
All times are GMT - 5 Hours
Page 1 of 1
|
|
|
|  |