Jump to content

Regex : How to remove white space before a string and after the string


Recommended Posts

Another problem :

$test = StringStripWS(" Enghien les bains ",3)

MsgBox(0,"result",$test)

It doesn't work with this example, the result is " Enghien les bains " but I need "Enghien les bains" (without first and last whitespace)

Can you try for me ?

Thanks :graduated:

Sambalec

Link to comment
Share on other sites

I don't know. It's working for me too.

$String = StringStripWS(" Hello there!  ", 3)
MsgBox(0, "Test", "|" & $String & "|")

If it doesn't work (I don't understand why) you must use StringTrimLeft and StringTrimRight.

Sorry for my bad English but nobody is perfect. [font=arial, helvetica, sans-serif]Ramzes[/font]

Link to comment
Share on other sites

I think its a big bug ... maybe encoding ...

I don't believe so! Can you post a very short script to replicate the issue?

Bonne baignade en tous cas !

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Did you run the script I posted? When I run the code, it gives me a message box saying the string contains 17 characters. Realize that spaces are characters and also form part of the string. If you got a message box saying the string contains 19 characters, then I will believe you.

Edited by czardas
Link to comment
Share on other sites

I think its a big bug ... maybe encoding ...

Are you sure that this is a whitespaces, and not any other characters? For example:

$test = StringStripWS(ChrW(160) & "Enghien les bains" & ChrW(160), 3)
ConsoleWrite($test & @CR)
Edited by Yashied
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...