• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Perl Regex (Regular Expression)

SuperNova

Junior Member
Hello,

I am working on a assignment and I need to write a Regular expression that meet the following criteria.

A floating-point literal (FPL) consists of two non-empty strings of ASCII digits separated with a period. The second string is optional. Leading zeros are not allowed in the first string, that is, 01.0, 002.0, .0, .7 are examples of illegal constants; 0.0, 0.00, 0.010, 0., 1., 880. are legal constants.

Thanks for the help!!
 
I would suggest that you get your hands on a good regular expression book..I came up with this by just glancing at one of my books.

^[0]{1}\.[0-9]{1,}$

^ indicates the beginning of the sentece/expression.

[0]{1} indicates that I expect a 0 in the beginning.

\. indicates I expect a period (".&quot😉

[0-9]{1,} indicates that I expect any digit between 0-9 atleast once but with no limit set. So things like 0, 01, 012, 0123... are all valid.

$ indicates the end of the sentence/expression, probably not necessary here..

Don't assume that this is right, but as something to guide you, hopefully, in the correct direction..Regards


 
Back
Top