anotherStr = str.replace(/\([\.-])/gi, "\\$1");

That should match either a . OR a -

I forgot about regexp literals - thinking about passing a string, in
which case you have to escape the escape character.

2009/2/9 Guy Morton <[email protected]>:
> I doubt it. Explain what you are trying to do and it'd be easier to help
> you.
> [] is for defining a set of matching characters. You shouldn't be trying to
> use | in there.
>
>
> On 09/02/2009, at 11:34 AM, Manu Dhanda wrote:
>
> Is this correct way to do that:
>
> var someStr:String = "12-88";
> var str:String = "12.88";
> anotherStr = str.replace(/\([.|-])/gi, "\\$1");
> var bool:Boolean = someStr.match(new RegExp("anotherStr ",'i');
>
> Am too much confused with RegExp now. Sorry for all the trouble.
>
> Sam Lai wrote:
>>
>> Escape them by doing \. instead of .
>>
>> You might also have to escape the escape character too, i.e. \\. instead.
>>
>> 2009/2/9 Manu Dhanda <[email protected]>:
>>>
>>> So, how can I exactly match "." OR "-" character correctly?
>>>
>>>
>>> Guy Morton wrote:
>>>>
>>>> In regexp syntax, "." means "match any character"
>>>>
>>>> On 06/02/2009, at 1:37 PM, Manu Dhanda wrote:
>>>>
>>>>>
>>>>> Hi Guyz,
>>>>> I am having this particular issue and at the moment not able to come
>>>>> out
>>>>> with a solution.
>>>>> Any help or direction to solution would be great.
>>>>>
>>>>> var someStr:String = "12-88";
>>>>> var str:String = "12.88";
>>>>> var bool:Boolean = someStr.match(new RegExp("str",'i');
>>>>>
>>>>> Here, the match returns true.
>>>>> I don't understand why "-" is being matched to "." returning TRUE.
>>>>>
>>>>> -Manu.
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/Flex-RegExp-issues-tp21865562p21865562.html
>>>>> Sent from the FlexCoders mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Flex-RegExp-issues-tp21865562p21905244.html
>>> Sent from the FlexCoders mailing list archive at Nabble.com.
>>>
>>>
>>>
>>> ------------------------------------
>>>
>>> --
>>> Flexcoders Mailing List
>>> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
>>> Alternative FAQ location:
>>> https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847
>>> Search Archives:
>>> http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups
>>> Links
>>>
>>>
>>>
>>>
>>
>>
>
> --
> View this message in
> context: http://www.nabble.com/Flex-RegExp-issues-tp21865562p21905350.html
> Sent from the FlexCoders mailing list archive at Nabble.com.
>
>
>
>
> 

Reply via email to