From: Jeppe Jakobsen Date: 2006-02-15T03:07:39+09:00 Subject: Scanning a string for decimal numbers ------=_Part_185_24913326.1139940444996 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Thank you for clearing things, up for me, but could you explain what the last part of the expression Wilson provided me with means? it's (?=3D[^\d]) 2006/2/13, Josef 'Jupp' SCHUGT : > > Hi! > > At Sun, 12 Feb 2006 08:12:47 +0900, Jeppe Jakobsen wrote: > > > > Will that expression include both integers and decimal numbers? > > [-+]?([1-9]\d*(\,[0-9]+)?)|(0(\,[0-9]+)?) > > has two parts: > > [-+]? > ([1-9]\d*(\,[0-9]+)?)|(0(\,[0-9]+)?) > > > The first one is an optional sign. The second one is an alternative > between to two cases: > > [1-9]\d*(\,[0-9]+)? > 0(\,[0-9]+)? > > Let's first consider the first case > > [1-9]\d*(\,[0-9]+)? > > It has two parts, namely > > [1-9]\d* > (\,[0-9])? > > The first part by itself covers all integers larger than zero. The > overall expression additionally covers all floating point numbers > larger than 1. > > Now the second case > > 0(\,[0-9]+)? > > This one covers zero and all decimal numbers larger than 0 and smaller > than 1. > > The regex I provided intentionally supports none of > > [+-],\d+ > [+-]0+\d+ > > You may as well use the shorter version > > [-+]?(([1-9]\d*(\,\d+)?)|(0(\,\d+)?)) > > Wait a moment, I am not sure if that is correct. To be on the safe > side I'd rather use one of these where anything that follows the > optional sign has been put into another pair of parentheses: > > [-+]?(([1-9]\d*(\,[0-9]+)?)|(0(\,[0-9]+)?)) > [-+]?((([1-9]\d*(\,\d+)?)|(0(\,\d+)?))) > > I am one of those guys who sometime run out of placeholders when doing > search and replace in vim (which has nine of them). > > Josef 'Jupp' Schugt > -- > Let the origin be the middle of the earth, p(x,r) be the probability > density for finding person x at distance r. Make sure that a permanent > solution of int_0^R p(x,r) dr < 1 exists for R being the instantanous > value of the distance between earth and mars. > > -- "winners never quit, quitters never win" ------=_Part_185_24913326.1139940444996--