Strings: "Hard Quotes"?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Strings: "Hard Quotes"?

backspaces
Is there a form of string in beanshell that is "opaque" .. i.e. does  
NOT evaluate backslashed expressions (like \b \n \\) etc?

This is quite important, in my opinion, because otherwise RegEx's  
become nearly impossible!

As an example:
The pattern:
     ((\d{2})|(\d))\/((\d{2})|(\d))\/((\d{4})|(\d{2}))
.. must be expressed with this string:
     "((\\d{2})|(\\d))\\/((\\d{2})|(\\d))\\/((\\d{4})|(\\d{2}))"

As you can see, this is really horrid and alas, one of several Java  
warts.

     -- Owen

Owen Densmore
http://backspaces.net - http://redfish.com - http://friam.org




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Reply | Threaded
Open this post in threaded view
|

Re: Strings: "Hard Quotes"?

Alexey Zinger
This is why I like to put regex stuff in properties files.

--- Owen Densmore <[hidden email]> wrote:

> Is there a form of string in beanshell that is "opaque" .. i.e. does  
> NOT evaluate backslashed expressions (like \b \n \\) etc?
>
> This is quite important, in my opinion, because otherwise RegEx's  
> become nearly impossible!
>
> As an example:
> The pattern:
>      ((\d{2})|(\d))\/((\d{2})|(\d))\/((\d{4})|(\d{2}))
> .. must be expressed with this string:
>      "((\\d{2})|(\\d))\\/((\\d{2})|(\\d))\\/((\\d{4})|(\\d{2}))"
>
> As you can see, this is really horrid and alas, one of several Java  
> warts.
>
>      -- Owen
>
> Owen Densmore
> http://backspaces.net - http://redfish.com - http://friam.org
>
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
> for problems?  Stop!  Download the new AJAX search engine that makes
> searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
> http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
> _______________________________________________
> Beanshell-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/beanshell-users
>


Alexey
2001 Honda CBR600F4i (CCS)
1992 Kawasaki EX500
http://bsheet.sourceforge.net


               
__________________________________________
Yahoo! DSL – Something to write home about.
Just $16.99/mo. or less.
dsl.yahoo.com



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Reply | Threaded
Open this post in threaded view
|

RE: Strings: "Hard Quotes"?

Daniel Leuck
In reply to this post by backspaces
Hi Owen,

I've spent a fair amount of time working with C# lately, and I have to
admit, when I am working on Java projects with regex needs I really miss
C#'s @"" verbatim string literals.

This sort of thing is trivial to add to BeanShell.  It is literally about 15
minutes of work. I tried it while experimenting with a BeanShell variant,
but it is arguably not in the spirit of the language.  There seems to be a
strong preference to limit the Java/BeanShell delta to optional typing,
closures, and dot-style property access.

I personally favor this addition to Java and BeanShell.  I hope to see
something like this in the Dolphin Language JSR (perhaps using back quotes
or borrowing the C# syntax.)

Cheers,
Daniel Leuck
http://www.ikayzo.com
http://www.ikayzo.org
http://www.javaui.net

> -----Original Message-----
> From: [hidden email] [mailto:beanshell-users-
> [hidden email]] On Behalf Of Owen Densmore
> Sent: Friday, December 30, 2005 1:21 PM
> To: [hidden email]
> Subject: [Beanshell-users] Strings: "Hard Quotes"?
>
> Is there a form of string in beanshell that is "opaque" .. i.e. does
> NOT evaluate backslashed expressions (like \b \n \\) etc?
>
> This is quite important, in my opinion, because otherwise RegEx's
> become nearly impossible!
>
> As an example:
> The pattern:
>      ((\d{2})|(\d))\/((\d{2})|(\d))\/((\d{4})|(\d{2}))
> .. must be expressed with this string:
>      "((\\d{2})|(\\d))\\/((\\d{2})|(\\d))\\/((\\d{4})|(\\d{2}))"
>
> As you can see, this is really horrid and alas, one of several Java
> warts.
>
>      -- Owen
>
> Owen Densmore
> http://backspaces.net - http://redfish.com - http://friam.org
>
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log
> files
> for problems?  Stop!  Download the new AJAX search engine that makes
> searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
> http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
> _______________________________________________
> Beanshell-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/beanshell-users



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users