1. How to exclude separation symbols from string?

Example: "I am Putin Worshipper" --> "IamPutinWorshipper"

find_replace(' ', String, '') -- dosn't work
new topic     » topic index » view message » categorize

2. Re: How to exclude separation symbols from string?

SnakeCharmer said...

Example: "I am Putin Worshipper" --> "IamPutinWorshipper"

find_replace(' ', String, '') -- dosn't work

Hi SnakeCharmer, Try

include std/sequence.e 
sequence oldstring = "I am Putin Worshipper" 
sequence newstring 
 
newstring = remove_all(' ', oldstring) 
printf(1, "%s\n", {newstring}) 
new topic     » goto parent     » topic index » view message » categorize

3. Re: How to exclude separation symbols from string?

SnakeCharmer said...

Example: "I am Putin Worshipper" --> "IamPutinWorshipper"

find_replace(' ', String, '') -- dosn't work

'' is not valid character, so in order to remove some characters you need to use remove_all() function instead, as Lnettnay suggested. In case you need to remove some substring (or replace it with another one) you can use match_replace() func:

puts(1,match_replace(" ", "I am Putin Worshipper", "")&'\n') -- "" is valid character string, so it works fine 
puts(1,match_replace("Putin", "I am Putin Worshipper", "Medvedev")&'\n') -- works too 
new topic     » goto parent     » topic index » view message » categorize

4. Re: How to exclude separation symbols from string?

Thanks!

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu