Sign in to follow this  
Followers 0
Syl21

RESOLVED: StringRegExp usage

6 posts in this topic

#1 ·  Posted (edited)

Data in excel:

Engineer

01082009000000

02082009000000

03082009000000

Contact Numbers Base

AutoIt Script:

$sCellValue=_ExcelReadCell($oExcel, $LIGNEDATE, $Colonne)

$test= StringRegExp ( $sCellValue, '[:digit:]{14}' )

MsgBox(0, "Error!", "debut"&$sCellValue&"fin donc resulat= "&$test)

$test always send "0"

I want $test="1" when data is like 02082009000000

Can you help me??? I don't know why that doesn't work...

Thanks in advance

Edited by Syl21

Share this post


Link to post
Share on other sites



I have found my solution:

$test= StringRegExp ( $sCellValue, "\d{14}" )

I don't know why [:digit:] don't work... If somebody know...

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Syl21,

I believe you need to use another set of [] when you use character classes:

$value = "02082009000000"

If StringRegExp($value, "[[:digit:]]{14}") = 1 Then ConsoleWrite("Hit" & @CRLF)

Or you could avoid any [] by using:

$value = "0208200900000"

If StringRegExp($value, "\d{14}") = 1 Then ConsoleWrite("Hit" & @CRLF)

And finally, as _ExcelReadCell returns a string, you could even use boring old string functions:

$value = "02082009000000"

If StringLen($value) = 14 And IsInt(Number($value)) Then ConsoleWrite("Hit" & @CRLF)

M23

Edit: I see you beat me to it! >_<

Edited by Melba23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Syl21,

I believe you need to use another set of [] when you use character classes:

$value = "02082009000000"

If StringRegExp($value, "[[:digit:]]{14}") = 1 Then ConsoleWrite("Hit" & @CRLF)

Or you could avoid any [] by using:

$value = "0208200900000"

If StringRegExp($value, "\d{14}") = 1 Then ConsoleWrite("Hit" & @CRLF)

And finally, as _ExcelReadCell returns a string, you could even use boring old string functions:

$value = "02082009000000"

If StringLen($value) = 14 And IsInt(Number($value)) Then ConsoleWrite("Hit" & @CRLF)

M23

Edit: I see you beat me to it! >_<

Thanks for your answer Fu...ng Bracket lol Have a good day

Share this post


Link to post
Share on other sites

How can i edit my post to write RESOLVE inside??? thanks in advance

Share this post


Link to post
Share on other sites

Syl21,

Edit your first post, but when the editing screen comes up, press the "Use Full Editor" button. You can then edit the title as well as the text.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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