| View previous topic :: View next topic |
| Author |
Message |
KDJ
Joined: 06 Mar 2010 Posts: 1064 Location: Poland
|
Posted: Thu Mar 07, 2013 12:07 pm Post subject: |
|
|
Thanks Instructor.
Now, "\0" generates a syntax error, so it's OK. |
|
| Back to top |
|
 |
KDJ
Joined: 06 Mar 2010 Posts: 1064 Location: Poland
|
Posted: Fri Mar 08, 2013 1:36 pm Post subject: |
|
|
Instructor
\Z
- it seems to me that it works well.
There is a problem with \A anchor:
\A
- matches to the border between any characters and to the end of the text:
\A.
- matches any single character.
In the new test version does not have changes that you have entered yesterday ("\0", "\0+", "\0*", "\0{2,}"): http://akelpad.sourceforge.net/forum/viewtopic.php?p=21420&highlight=#21420 |
|
| Back to top |
|
 |
KDJ
Joined: 06 Mar 2010 Posts: 1064 Location: Poland
|
Posted: Fri Mar 08, 2013 3:23 pm Post subject: |
|
|
I found still these bugs:
\Z - also matches "Z" character,
.\A - also matches any character plus "A" (eg: "BA", "CA"). |
|
| Back to top |
|
 |
Instructor Site Admin
Joined: 06 Jul 2006 Posts: 4636
|
Posted: Sat Mar 09, 2013 6:40 am Post subject: |
|
|
KDJ
| KDJ wrote: |
There is a problem with \A anchor:
\A
- matches to the border between any characters and to the end of the text:
\A.
- matches any single character. | It is so, if you press "Find next". Because:
| AkelHelp-Eng.htm wrote: | \A Matches the position at the beginning of the search range.
\Z Matches the position at the end of the search range.
|
| Quote: | | In the new test version does not have changes that you have entered yesterday ... | Already merged.
| Quote: | | I found still these bugs... | Test version |
|
| Back to top |
|
 |
KDJ
Joined: 06 Mar 2010 Posts: 1064 Location: Poland
|
Posted: Sat Mar 09, 2013 1:44 pm Post subject: |
|
|
Instructor
Thank you very much, now everything is OK.
In AkelHelp-Eng.htm:
- description of expression "(?<!pattern)" is truncated,
- You can add that "\z" is equivalent "\Z". |
|
| Back to top |
|
 |
Instructor Site Admin
Joined: 06 Jul 2006 Posts: 4636
|
Posted: Sun Mar 10, 2013 9:48 am Post subject: |
|
|
| KDJ wrote: | | description of expression "(?<!pattern)" is truncated | Corrected. |
|
| Back to top |
|
 |
KDJ
Joined: 06 Mar 2010 Posts: 1064 Location: Poland
|
Posted: Sun Mar 10, 2013 12:26 pm Post subject: |
|
|
The following two regular expressions work in different ways:
\w+(\W*)
\w+\W*
In the first regexp, the "+" quantifier is lazy (non-greedy).
In the second, the "+" quantifier is greedy.
However, you may need to implement two types of quantifiers:
- greedy: ?, *, +, {n1,n2}
- lazy: ??, *?, +?, {n1,n2}?
| Instructor wrote: | \A Matches the position at the beginning of the search range.
\Z Matches the position at the end of the search range. |
Can you still add:
\a - matches the position at the beginning of the string.
\z - matches the position at the end of the string. |
|
| Back to top |
|
 |
Instructor Site Admin
Joined: 06 Jul 2006 Posts: 4636
|
Posted: Fri Mar 15, 2013 8:29 am Post subject: |
|
|
| KDJ wrote: | | The following two regular expressions work in different ways... | Test version
| KDJ wrote: | Can you still add:
\a - matches the position at the beginning of the string.
\z - matches the position at the end of the string. | Don't understand the request. Can you explain with examples? |
|
| Back to top |
|
 |
KDJ
Joined: 06 Mar 2010 Posts: 1064 Location: Poland
|
Posted: Fri Mar 15, 2013 8:00 pm Post subject: |
|
|
Instructor
I need to replace the first and last character in the text on "x".
Text:
What: \A.|.\Z
With: x
Result (Replace all):
It was to be:
Such anchors are needed to indicate the beginning and end of the text, no the beginning/end of the search range.
And one more thing. These expressions work in different ways:
(\Ab)|(b\Z)
\Ab|b\Z |
|
| Back to top |
|
 |
Instructor Site Admin
Joined: 06 Jul 2006 Posts: 4636
|
Posted: Sat Mar 16, 2013 10:09 am Post subject: |
|
|
| Quote: | | These expressions work in different ways... |
Test version |
|
| Back to top |
|
 |
KDJ
Joined: 06 Mar 2010 Posts: 1064 Location: Poland
|
Posted: Sat Mar 16, 2013 1:25 pm Post subject: |
|
|
Instructor
If:
\A - matches the position at the beginning of the search range,
\Z - matches the position at the end of the search range,
in the previous test version it worked well.
In the new test version it is inconsistent.
In the above example, regexp matches 9 times (8 times "b" and 1 time new line), and replaces only 2 times.
I propose to add two new anchors \a, \z (or change the way of working \A, \Z), so that:
\a - matches the position at the start of the text,
\z - matches the position at the end of the text.
"\a" should match only the beginning of the text (only once), like "^" matches only the beginning of the line (only once, if there is one line).
It seems to me that this is a well done in SynWrite: http://www.uvviewsoft.com/synwrite/ |
|
| Back to top |
|
 |
cnnnc
Joined: 12 Jan 2008 Posts: 115 Location: Shantou, China
|
Posted: Mon Mar 18, 2013 2:43 am Post subject: |
|
|
| Code: | 123 abc abc abc abc
456 def def def
789 ghi ghi | Ctrl+F | Code: | | (\w+)\t(\w+)(\t\2)+ | [v]Regular Expression
(*)Beginning
It's can't find any. But SearchReplace.js can.
I have to try | Code: | | (\w+)\t(\w\w\w)(\t\2)+ | --------------------
WinXP SP3 ChineseSimplified With most safe hotfix
AkelPad 4.8.1+ |
|
| Back to top |
|
 |
Instructor Site Admin
Joined: 06 Jul 2006 Posts: 4636
|
Posted: Thu Mar 21, 2013 5:47 am Post subject: |
|
|
KDJ
| AkelHelp-Eng.htm wrote: | \A Matches the position at the beginning of the document...
\Z Matches the position at the end of the document...
\a Same as \A, but matches the position at the beginning of the search range.
\z Same as \Z, but matches the position at the end of the search range. |
cnnnc
| Quote: | | (\w+)\t(\w+)(\t\2)+ |
Test version |
|
| Back to top |
|
 |
cnnnc
Joined: 12 Jan 2008 Posts: 115 Location: Shantou, China
|
Posted: Thu Mar 21, 2013 7:30 am Post subject: |
|
|
| Instructor wrote: | cnnnc
| Quote: | | (\w+)\t(\w+)(\t\2)+ |
Test version |
OK. |
|
| Back to top |
|
 |
KDJ
Joined: 06 Mar 2010 Posts: 1064 Location: Poland
|
Posted: Thu Mar 21, 2013 8:32 pm Post subject: |
|
|
| Instructor wrote: | \A Matches the position at the beginning of the document...
\Z Matches the position at the end of the document...
\a Same as \A, but matches the position at the beginning of the search range.
\z Same as \Z, but matches the position at the end of the search range. |
"Find" works well.
You need a bit to improve "Replace all".
Text (at the end is new line char):
What: \A.|.\Z
With: x
Result of Replace all:
It should be:
What: \a.|.\z
With: x
Result of Replace all:
It should be:
|
|
| Back to top |
|
 |
|