Re: [flexcoders] Flex RegExp issues
The dot character matches "any character", so that the regex "12.0" will match "12-0", "12x0", "12P0" etc. If you want to match the "dot" itself, you have to escape it, i.e. "12\.0". Haykel Ben Jemia Allmas Web & RIA Development http://www.allmas-tn.com On Mon, Feb 9, 2009 at 1:54 AM, Manu Dhanda wrote: > > The problem is: > I am trying to filter an arraycollection(labels) against the text. Using a > filter function and in there I am trying to use RegExp. > > More specifically, whenever I enter a text like 12.0, it returns me results > with "-" character as well like 12-0 etc. > > So I want that whenever I enter "." in my search, it should only return me > results with "." and NOT "-" and vice-versa. > > Thanks, > Manu. > >
Re: [flexcoders] Flex RegExp issues
The problem is: I am trying to filter an arraycollection(labels) against the text. Using a filter function and in there I am trying to use RegExp. More specifically, whenever I enter a text like 12.0, it returns me results with "-" character as well like 12-0 etc. So I want that whenever I enter "." in my search, it should only return me results with "." and NOT "-" and vice-versa. Thanks, Manu. Guy Morton wrote: > > \. will match a literal full stop. > \\ will match a backslash. > - will match normally without being escaped, so long as it's not in > the context of a character range (ie [a-z] means match any character > from a to z, to match a, - or z you'd do [a\-z]) > > Guy > > On 09/02/2009, at 11:24 AM, 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 : >> > >> > 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-tp21865562p21905504.html Sent from the FlexCoders mailing list archive at Nabble.com.
Re: [flexcoders] Flex RegExp issues
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 : > 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 : >>> >>> 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. > > > > >
Re: [flexcoders] Flex RegExp issues
\. will match a literal full stop. \\ will match a backslash. - will match normally without being escaped, so long as it's not in the context of a character range (ie [a-z] means match any character from a to z, to match a, - or z you'd do [a\-z]) Guy On 09/02/2009, at 11:24 AM, 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 : > > 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 > > > >
Re: [flexcoders] Flex RegExp issues
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 : >> >> 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.
Re: [flexcoders] Flex RegExp issues
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 : >> >> 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.
Re: [flexcoders] Flex RegExp issues
Escape them by doing \. instead of . You might also have to escape the escape character too, i.e. \\. instead. 2009/2/9 Manu Dhanda : > > 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 > > > >
Re: [flexcoders] Flex RegExp issues
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.
Re: [flexcoders] Flex RegExp issues
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-tp21865562p21905239.html Sent from the FlexCoders mailing list archive at Nabble.com.
Re: [flexcoders] Flex RegExp issues
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.