Jump to content

RESOLVED: StringRegExp usage


Syl21
 Share

Recommended Posts

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
Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
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
Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

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...