/    Sign up×
Community /Pin to ProfileBookmark

removing character from text

there is string which has space
now the unicode of this space(character) is not 32 but 160.
how to remove all the occurence of character having unicode as 160 from given string

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@JUDJul 22.2006 — [CODE]
<script type="text/javascript">
// <![CDATA[
var txt = "The cow jumped over the moon";
var letters = txt.split("");

for(var i = 0; i < letters.length; i++){
if(letters[i].charCodeAt(0) == 160){
delete letters[i];
}
}

txt = letters.join("");

alert(txt);
// ]]>
</script>
[/CODE]


[B]Note :[/B] Character code 160 has no effect on the string in the example. Try code 111. This will remove all the 'o's'.
Copy linkTweet thisAlerts:
@Orc_ScorcherJul 22.2006 — yourString = yourString.replace(/u00a0/g, "")
×

Success!

Help @BII spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...