Quantcast
Viewing all articles
Browse latest Browse all 186

Deleting all characters in a string that do not belong to a small set of elements

Say I have a string {100 aa bbc%j%b%wa ajjcj11j0%2wj fc} with a lot of undesired characters or spaces in it, for example: {"", "%", "w", "j"}. I'd like to strip the string of these characters, with the provided example giving us the output string:

testString = "100 aa bbc%j%b%wa ajjcj11j0%2wj fc";StringReplace[testString, {"", "%", "w", "j"} -> ""]out: "100aabbcbaac1102fc";

Now, say we don't have a convenient list of undesired characters / spaces / paragraph indicators / etc. Is there a way to select for certain characters instead of specifying that certain characters should be deleted (as in the example)?


Viewing all articles
Browse latest Browse all 186

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>