Sign in to follow this  
Followers 0
AlmarM

Replace all NON "A-Z, a-z" characters inside a string

3 posts in this topic

Hiya!

How do I replace all non "A-Z, a-z" characters inside a string? I think I should use StringRegExpReplace, but I have no idea how to get the right pattern.

For example:

User enters: "Europe"
Action Taken: None, there are no other characters detected.

User enters: " Europe"
Action Taken: Replace " " with ""

User enters: "12Europe"
Action Taken: Replace "12" with ""

User enters: "(Europe)"
Action Taken: Replace "(", ")" with ""

So as you can see, only "A-Z, a-z" characters are allowed.

Thanks! ;)


Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Try it:

$UserEnters = ' 1(2E[u]ro)p e'
MsgBox(0, "Regular Expression Replace Test", StringRegExpReplace($UserEnters, '[^a-zA-Z]|\W', ''))

Edited by Danny35d

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

Share this post


Link to post
Share on other sites

Try it:

$UserEnters = ' 1(2E[u]ro)p e'
MsgBox(0, "Regular Expression Replace Test", StringRegExpReplace($UserEnters, '[^a-zA-Z]|\W', ''))

Hey thanks! ^^

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
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
Sign in to follow this  
Followers 0