[kepler-users] how to replace some strings to backslash ("\")?

Jianwu Wang jianwu at sdsc.edu
Fri May 3 16:00:17 PDT 2013


Hi Christopher,

     Thanks for your help. I want the result to be: backslash, b and c. 
Your suggestion returns: "bc. Try replaceAll("a", "\\") also doesn't work.

     I know backslash is special and haven't found a way to work around. 
It's fine if we conclude that backslash cannot be at target string in 
expression language. I'll think other ways to do it.

     I attached a small model for you to test.

Best wishes

Sincerely yours

Jianwu Wang, Ph.D.
jianwu at sdsc.edu
http://users.sdsc.edu/~jianwu/

Assistant Project Scientist
Scientific Workflow Automation Technologies (SWAT) Laboratory
San Diego Supercomputer Center
University of California, San Diego
San Diego, CA, U.S.A.

On 5/3/13 3:35 PM, Christopher Brooks wrote:
> Hi Jianwu,
> You would need to protect the backslash with a backslash.
> Try replaceAll("a", "\\"")
> I'm not sure if that will work.
>
> In general, backslashes are somewhat evil.
>
> For example: Is the string "\bc" three characters: backslash, b and c  
> or two characters: backspace and c?
>
> I'm not sure what replaceAll method you are calling here, I'm guessing 
> you are invoking that method on a String?
>
> A small test model would help.
>
> I'm not confident that backslashes work well in the expression lange.
>
> _Christopher
>
> On 5/3/13 3:16 PM, Jianwu Wang wrote:
>> Hi Christopher,
>>
>>     I'm using "Expression Evaluator" trying to replace some strings 
>> to backslash, such as from "abc" to "\bc". Command like 
>> replaceAll("a","\") always has error: Found unterminated string : 
>> "\"). Similar attempts also failed.
>>
>>     I searched Kepler/Ptolemy documents and mailing lists and didn't 
>> find answer. Would you please help me out? Thanks.
>>
>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: replace-string-2-backslash.xml
Type: text/xml
Size: 33408 bytes
Desc: not available
URL: <http://lists.nceas.ucsb.edu/kepler/pipermail/kepler-users/attachments/20130503/7d420936/attachment-0001.xml>


More information about the Kepler-users mailing list