Jump to content

regexp not match only digit


 Share

Recommended Posts

You're using the no wanted string in the pattern. 

#include <Array.au3>

Local $iLIP1 = StringRegExp('Anakin."120" Yoda', '\d+', 3)
_ArrayDisplay($iLIP1, "ana")

Saludos

Link to comment
Share on other sites

ok but if i have text  much long  of

'Anakin."120" Yoda'

this  and  in middle of text have  2 marker  Anakin   and  yoda  and in middle  a number  , why my exprfession dont katch ? only number?

Edited by faustf
Link to comment
Share on other sites

If you want 120 extracted from the sample text, then try this.

#include <Array.au3>

Local $aLIP1 = StringRegExp('Star."100" Anakin."120" Yoda."140" Wars', 'Anakin\."(\d+)" Yoda', 3) ; "(\d+)" - this group captures only digits.
_ArrayDisplay($aLIP1, "ana") ; Array only contains $aLIP1[0] = 120

; or

MsgBox(0, "Result", StringRegExp('Star."100" Anakin."120" Yoda."140" Wars', 'Anakin\."(\d+)" Yoda', 3)[0])

 

Edited by Malkey
Changed "." to "\.'" in RE pattern in order to match a literal dot, ".".
Link to comment
Share on other sites

Then you use () to embed the wanted part:

Local $iLIP1= StringRegExp('Anakin."120" Yoda', 'Anakin."(\d+)" Yoda', 3) ; currently untested

Simpel

SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

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

Link to comment
Share on other sites

do you always just need the thing that is in double quotes?  just regexing for fun?

msgbox(0, '' , stringsplit('Anakin."120" Yoda' , '"' , 2)[1])

 

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

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