May 31, 2009 Re: legal identifier check | ||||
---|---|---|---|---|
| ||||
Posted in reply to BCS |
> if you are only working with ASCII: use the regex `_A-Za-z[_A-Za-z0-9]*`
Is that better than the inPattern way?
|
May 31, 2009 Re: legal identifier check | ||||
---|---|---|---|---|
| ||||
Posted in reply to Saaa | Hello Saaa,
>> if you are only working with ASCII: use the regex
>> `_A-Za-z[_A-Za-z0-9]*`
>>
> Is that better than the inPattern way?
>
yes, it correctly rejects numbers at the start and should be faster as well.
|
May 31, 2009 Re: legal identifier check | ||||
---|---|---|---|---|
| ||||
Posted in reply to BCS | > Hello Saaa,
>
>>> if you are only working with ASCII: use the regex `_A-Za-z[_A-Za-z0-9]*`
>>>
>> Is that better than the inPattern way?
>>
>
> yes, it correctly rejects numbers at the start and should be faster as well.
Of course, should have looked longer at the regex line, thanks!
|
June 01, 2009 Re: legal identifier check | ||||
---|---|---|---|---|
| ||||
Posted in reply to BCS | BCS wrote:
> Hello Saaa,
>
>>> You have to write it yourself. Here's a good starting point:
>>> http://www.digitalmars.com/d/1.0/lex.html#identifier
>>>
>> Yes, that was my starting point and it seemed quite complex, thus my
>> question :)
>> I think I'll stay with my simple check for now as it isn't really
>> necessary
>> to be as strict as D's identifiers.
>> Just thought that if there was an easy check I'd implement that.
>> Thanks anyways everybody.
>
> if you are only working with ASCII: use the regex `_A-Za-z[_A-Za-z0-9]*`
Isn't there an isUniAlpha function in both Phoboses and in Tango?
|
June 01, 2009 Re: legal identifier check | ||||
---|---|---|---|---|
| ||||
Posted in reply to BCS Attachments:
| BCS wrote: > Hello Saaa, > >>> You have to write it yourself. Here's a good starting point: http://www.digitalmars.com/d/1.0/lex.html#identifier >>> >> Yes, that was my starting point and it seemed quite complex, thus my >> question :) >> I think I'll stay with my simple check for now as it isn't really >> necessary >> to be as strict as D's identifiers. >> Just thought that if there was an easy check I'd implement that. >> Thanks anyways everybody. > > if you are only working with ASCII: use the regex `_A-Za-z[_A-Za-z0-9]*` > Shouldn't that be "[_A-Za-z][_A-Za-z0-9]*"? Jerome -- mailto:jeberger@free.fr http://jeberger.free.fr Jabber: jeberger@jabber.fr |
June 01, 2009 Re: legal identifier check | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jérôme M. Berger | Reply to Jérôme,
> BCS wrote:
>
>> Hello Saaa,
>>
>>>> You have to write it yourself. Here's a good starting point:
>>>> http://www.digitalmars.com/d/1.0/lex.html#identifier
>>>>
>>> Yes, that was my starting point and it seemed quite complex, thus my
>>> question :)
>>> I think I'll stay with my simple check for now as it isn't really
>>> necessary
>>> to be as strict as D's identifiers.
>>> Just thought that if there was an easy check I'd implement that.
>>> Thanks anyways everybody.
>> if you are only working with ASCII: use the regex
>> `_A-Za-z[_A-Za-z0-9]*`
>>
> Shouldn't that be "[_A-Za-z][_A-Za-z0-9]*"?
>
> Jerome
>
Oops :(
|
Copyright © 1999-2021 by the D Language Foundation