Macro get_word()?
Bert Wesarg
wesarg at informatik.uni-halle.de
Mon Jan 22 21:27:12 CET 2007
Tony Balinski wrote:
> Quoting Bert Wesarg <wesarg at informatik.uni-halle.de>:
>
>> Yes,
>>
>> this is my actual code, to check if $cursor is on a right word boundary:
>>
>> define is_right {
>> rwb = -1
>> if ($cursor > 0) {
>> rwb = search(">", $cursor - 1, "forward", "regex")
>> } else if ($cursor < $text_length) {
>> rwb = search(">", $cursor + 1, "backward", "regex")
>> }
>> if ($cursor != rwb) {
>> return 0
>> }
>> return 1
>> }
>
> You want a predicate to test the current position.
> Why not just:
> return search(">", $cursor, "regex")
Hmm, never tried this, but it works, thanks
Bert
> which is much the same as
> return search("(?<=\\w)(?=\\W|$)", $cursor, "regex") == $cursor
>
> Likewise for lwb: "<" or "?<=^|\\W)(?=\\w)"
>
> Tony
More information about the Discuss
mailing list