Skip to main content
Participant
March 21, 2008
Question

regexp instantiation behaves weird

  • March 21, 2008
  • 3 replies
  • 282 views
OK this is driving me nuts, can a forum admin PLEASE investigate why I have been unable to post the following message to your forums...every time I've tried it complains that I've used "censored word(s)" . You can read the full post by following the link below, I've read it ten times and cant find anything that should trigger that filter. I even tried removing the code blocks but nothing helped:

http://www.geocities.com/snafu7x7/as3post.html
This topic has been closed for replies.

3 replies

snafu7x7Author
Participant
March 21, 2008
actually Raymond, I just uncovered that very item after googling all day I found an Adobe Press publication that actually documents it...(its nowhere in the AS3 doc I could find). To read the specifics check it out:

http://books.google.com/books?id=DT7INNE3ui8C&pg=PA252&lpg=PA252&dq=action+script+escape+slashes+regexp&source=web&ots=K5gKG5Oa9T&sig=QmrZcaDWzl9ysBfFRgQDptBZSlA&hl=en#PPA252,M1

To me this is borderline retarded...treating it one way for the constructor and another for the inline version, especially where regex has so many back slashes inherent to its syntax. Btw, your example is not 'quite' correct for two reasons:

1)if you do use the constructor version you don't use the forward slashes to start and end it, you just include the actual regexp (with all backslashes escaped) in the string variable to the constructor)
2)for some reason that I haven't been able to track down, named back references do not work if you use the string constructor. I was able to get my url regex working by removing all the named back references and escaping all backslashes.
Inspiring
March 21, 2008
You need to escape all your backslashes when you use the constructor.
i.e
/(?P(\w|[_.\-])+)@(?P((\w|-)+))+\.\w{2,4}+/
would need to be
"/(?P(\\w|[_.\\-])+)@(?P((\\w|-)+))+\\.\\w{2,4}+/"


snafu7x7Author
Participant
March 21, 2008
oh and please read the actual post too and chime in if you have any idea why that might be happening