Skip to main content
deleted 2 characters in body
Source Link
Nasser
  • 150.6k
  • 12
  • 162
  • 376

One way is to use RegularExpression

str = "This is, my string number 5!";
reg = RegularExpression["[A-Za-z0-9 ]"];
StringJoin[StringCases[str, reg]] // InputForm

gives

"This is my string number 5"

The " " is for any space, and [AA-Za-z0-9]9 stuff is for alpha numeric.

One way is to use RegularExpression

str = "This is, my string number 5!";
reg = RegularExpression["[A-Za-z0-9 ]"];
StringJoin[StringCases[str, reg]] // InputForm

gives

"This is my string number 5"

The " " is for any space, and [A-Za-z0-9] stuff is for alpha numeric.

One way is to use RegularExpression

str = "This is, my string number 5!";
reg = RegularExpression["[A-Za-z0-9 ]"];
StringJoin[StringCases[str, reg]] // InputForm

gives

"This is my string number 5"

The " " is for any space, and A-Za-z0-9 stuff is for alpha numeric.

Source Link
Nasser
  • 150.6k
  • 12
  • 162
  • 376

One way is to use RegularExpression

str = "This is, my string number 5!";
reg = RegularExpression["[A-Za-z0-9 ]"];
StringJoin[StringCases[str, reg]] // InputForm

gives

"This is my string number 5"

The " " is for any space, and [A-Za-z0-9] stuff is for alpha numeric.