Jump to content

strip out letters from a string


gcue
 Share

Recommended Posts

Because you set the flag to 1 - use 3 but also change search pattern to "(?i)[a-z]".

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

You have to invers the search pattern:

#include <array.au3>

$string = "AbC12D22"

$string = StringUpper($string)
$new = StringRegExp($string, "(?i)[a-z]", 3)
_ArrayDisplay($new)
$snew = StringRegExpReplace($string, "(?i)[\d]", "$1")
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $snew = ' & $snew & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Strip letters or numbers from string?

$string = "AbC12D22"

$new = StringRegExpReplace($string, "[0-9]", "")   ; Reslts in $new = "AbCD"
MsgBox(0,"Result",$New) ;

$new = StringRegExpReplace($string, "[^0-9]", "") ; Reslts in $new = "1222"
MsgBox(0,"Result",$New) ;

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...