troubleshooting Question

replacing characters within a delimited string (i.e. " quotes)

Avatar of rechard
rechard asked on
C
6 Comments1 Solution372 ViewsLast Modified:
hello experts

Her eis my problem, that I have been struggling with. I am writing a library (SO) on soalris to be used by some 3rd party application. It accepts calls to internal procedures using its own language given you pass it through their c function, which is run_code(arg);

So I have to pass in the internal call to this function run_code(arg). Thus I have a line that looks like

run_code(internalFunction/SubRoutine("arg1", "arg2", ..., "arg n"))

The problem is if any of the args to the internal function call have any of the following characters in its string (i.e " quote, ' single quote, \ backslash, or ) right parenthesis) then it has a problem. The run_code function, which is vendor propietary can not handle these characters, thus I need to replace any of these special characters with "entity refernece" and then replace it once we get through this wall (run_code)... Thus I want to do the following....

Given this call...

run_code(Class/Method("my argument with special chars is: )'"\", "next arg", "last arg"))

needs to be turned into this

run_code(Class/Method("my argument with special chars is: #rpar;#apos;#quot;#bksl;", "next arg", "last arg"))

were
) -> #rpar;
\ -> #bksl;
' -> #apos;
" -> #quot;

I have a wonderful substring replacement function that I wrote, that would work great if I could break this into tokens successfully... replacing the single quot and backslash really aren't a problem because they are not special within the function call itself... I can just do a substring replacement for single quot and backslash for the whole string... the problem is the " double quote and ) right parenthesis...

What I need is something that will read this string... and give me a substring that I can do replacements on, were the substring is delimited by "...", or "..."))
that is give me a sub string if it begins with " has some stuff and is followed by ", " (i include comma b/c there may be " in the argument) or " ... ")) and 2 parenthesis followed by no more characters or white space... (signaling end of call.. i.e. last argument)

Sorry if that is confusing.. it is confusing me too.. that is why I need help. In simple words I need a way to replace the following character " ' ) and \ when they are used as characters in the argument portion of the call below.

run_code(Class/Method("my argument with special chars is: )'"\", "next arg", "last arg"))

Any help, thoughts, or ideas...?? pseudo code, examples greatly welcomed... This should be highly flexible in case the user

Thanks in advance

rechard
ASKER CERTIFIED SOLUTION
jcaldwel

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros