Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

string manipulation

-- I have a string S. There is a character '>' in S. I want to insert a new string in between '>' and the character before '>'. What's the best way to do this? -- I have a string S. There is a character ';' and '@' in S. I want to remove all character in between ';' (including this) and '@' (not including this). What's the best way to do this?
0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER
Hi Romel,

Does the first string S have more than one >'s in it? If so can you provide some sanitized examples of the original and updated versions?

Likewise, are there more than one ; or @ character in the second string? Can you also provide some sanitized examples of the original and updated versions for that scenario?

Aaron
0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER
Example for 1st case: 12344384616;cic=0335@@645.444.44 Example for 2nd case: <34384616@66.106ddsdsd>
0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER
Maybe something like these?

set str1 "12344384616;cic=0335@@645.444.44"

# scan $str1 and save everything that isn't a ; into a.
# Save everything after ; up to the next @ into b
# Save everything after the @ into c
scan $str1 {%[^;];%[^@]@%s} a b c

# Append $a and $c
set str1_edited "$a$c"

Result: 12344384616@645.444.44

# Replace all >'s with inserted_string>
string map {">" "inserted_string>"} "<34384616@66.106ddsdsd>"

Result: <34384616@66.106ddsdsdinserted_string>

Aaron
0