Discussion:
please help with my regular expression
John Ferrier
2009-02-20 17:15:35 UTC
Permalink
The following regular expression used in fortan language to match numerical constant

<[0-9]+(\.[0-9]*)?([DEde][-+]?[0-9]*)?|\.[0-9]+([DEde][-+]?[0-9]*)?>

works fine in most cases. However, for a line like

format (1X,F10.3)


it highlights the "3" unexpectedly.


Can anybody tell how to modify to make it work better?


Thanks,

John
--
NEdit Discuss mailing list - Discuss-***@public.gmane.org
http://www.nedit.org/mailman/listinfo/discuss
Bert Wesarg
2009-02-20 17:50:34 UTC
Permalink
Post by John Ferrier
The following regular expression used in fortan language to match numerical constant
<[0-9]+(\.[0-9]*)?([DEde][-+]?[0-9]*)?|\.[0-9]+([DEde][-+]?[0-9]*)?>
You should not use <> as 'delimiters', because that would not work
with a '.' inside. Try this:

(?<!\Y)[0-9]+(\.[0-9]*)?([DEde][-+]?[0-9]*)?|\.[0-9]+([DEde][-+]?[0-9]*)?(?!\Y)

Bert
--
NEdit Discuss mailing list - Discuss-***@public.gmane.org
http://www.nedit.org/mailman/listinfo/discuss
John Ferrier
2009-02-20 19:37:43 UTC
Permalink
It make no difference. The following works:

<[0-9]+(\.[0-9]*)?([DEde][-+]?[0-9]*)?|[0-9]*\.[0-9]+([DEde][-+]?[0-9]*)?>

Thanks anyway.

John


________________________________
From: Bert Wesarg <bert.wesarg-gM/Ye1E23mwN+***@public.gmane.org>
To: General NEdit discussion list <discuss-***@public.gmane.org>
Sent: Friday, February 20, 2009 11:50:34 AM
Subject: Re: please help with my regular expression
Post by John Ferrier
The following regular expression used in fortan language to match numerical constant
<[0-9]+(\.[0-9]*)?([DEde][-+]?[0-9]*)?|\.[0-9]+([DEde][-+]?[0-9]*)?>
You should not use <> as 'delimiters', because that would not work
with a '.' inside. Try this:

(?<!\Y)[0-9]+(\.[0-9]*)?([DEde][-+]?[0-9]*)?|\.[0-9]+([DEde][-+]?[0-9]*)?(?!\Y)

Bert
--
NEdit Discuss mailing list - Discuss-***@public.gmane.org
http://www.nedit.org/mailman/listinfo/discuss
--
NEdit Discuss mailing list - Discuss-***@public.gmane.org
http://www.nedit.org/mailman/listinfo/discuss
Loading...