Jump to content

StringRegExp tilde - (Moved)


jcpetu
 Share

Recommended Posts

Hi there,

I'm trying to create a little script using StringRegExp to filter the interface connection status, but I can't make the appropriate expression to filter letters with tilde in spanish. 

This is what I have by now:

#include <Array.au3>
#include <constants.au3>

Local $interface = Run("netsh interface show interface wi-fi", "", @SW_HIDE, $STDOUT_CHILD)
Local $output = ""
While 1
    $output &= StdoutRead($interface)
    If @error Then ExitLoop
WEnd
ConsoleWrite($output & @CRLF)

$Status = StringRegExp($output, "(?m).+\hEstado de conexión+\h+\h+(.*)\s", 3)

If Not @error Then ConsoleWrite("Status: " & $Status & @CRLF)

Any help will be appreciated!

Link to comment
Share on other sites

Post subject and expected result strings.

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

Hi jchd, when running netsh interface show interface wi-fi you get:

Wi-Fi
   Tipo:                 Dedicado
   Estado administrativo: Habilitado
   Estado de conexión:        Conectado

And I'm using StringRegExp to extract: Conectado

The code I corrected is:

#include <Array.au3>
#include <constants.au3>

Local $interface = Run("netsh interface show interface wi-fi", "", @SW_HIDE, $STDOUT_CHILD)
Local $output = ""
While 1
    $output &= StdoutRead($interface)
    If @error Then ExitLoop
WEnd
ConsoleWrite($output & @CRLF)

$Status = StringRegExp($output, "(?m).+\hEstado de conexión+\h+\h+(.*)\s", 3)
_ArrayDisplay($Status )
If Not @error Then ConsoleWrite("Status: " & $Status[0] & @CRLF)

 

Link to comment
Share on other sites

  • Developers

Moved to the appropriate forum, as the AutoIt Example Scripts forum very clearly states:

Quote

Share your cool AutoIt scripts, UDFs and applications with others.


Do not post general support questions here, instead use the AutoIt Help and Support forums.

Moderation Team

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Hi mikel, thls for your help.

It doesn't work. It doesn't output anything.

I would like to get the result in an array to been able to use it in a list view where I would like to show the connection status for different interfaces.

For example, if I use this little piece of code I got an array with the result:

#include <Array.au3>
#include <constants.au3>

Local $interface = Run("netsh interface show interface wi-fi", "", @SW_HIDE, $STDOUT_CHILD)
Local $output = ""
While 1
    $output &= StdoutRead($interface)
    If @error Then ExitLoop
WEnd
;ConsoleWrite($output & @CRLF)

$status = StringRegExp($output, "(?m).+\hTipo:+\h+\h+(.*)\s", 3)
;$status = StringRegExp($output, "(?m).+\hEstado de conexión+\h+\h+(.*)\s", 3)
;$status = StringRegExpReplace($output, "(?s).+Estado de conexión:\h+(\w+).*", "$1")

_ArrayDisplay($Status )
If Not @error Then ConsoleWrite("Status: " & $Status[0] & @CRLF)

image.png.773489a897ffa9e84fcceadd8d965a4f.png

Link to comment
Share on other sites

This works for me

#include <Array.au3>

$output = "Wi-Fi" & @crlf & _ 
    "   Tipo:                 Dedicado" & @crlf & _ 
    "   Estado administrativo: Habilitado" & @crlf & _ 
    "   Estado de conexión:        Conectado"

$status = StringRegExp($output, "Estado de conexión:\h+(\w+)", 3) 
_ArrayDisplay($status)

$all = StringRegExp($output, ":\h+(\w+)", 3) 
_ArrayDisplay($all)

 

Link to comment
Share on other sites

I just tried the code below and it works nice on my PC
What exactly doesn't work for you ?

#include <Array.au3>
#include <constants.au3>

Local $interface = Run("netsh interface ip show config", "", @SW_HIDE, $STDOUT_CHILD)
Local $output = ""
While 1
    $output &= StdoutRead($interface)
    If @error Then ExitLoop
WEnd
;Msgbox(0,"", $output)

$all = StringRegExp($output, ":\h+(.+)", 3) 
_ArrayDisplay($all)

 

Link to comment
Share on other sites

mikell

when running netsh interface show interface wi-fi you get:

Wi-Fi
   Tipo:                 Dedicado
   Estado administrativo: Habilitado
   Estado de conexión:        Conectado

And I'm using StringRegExp to extract only the value of Estado de conexión, in this case the result would beConectado

 

Link to comment
Share on other sites

mikel, with the point it works!

Thanks a lot.

 

#include <Array.au3>
#include <constants.au3>

Local $interface = Run("netsh interface show interface wi-fi", "", @SW_HIDE, $STDOUT_CHILD)
Local $output = ""
While 1
    $output &= StdoutRead($interface)
    If @error Then ExitLoop
WEnd
ConsoleWrite($output&@CR)

$status = StringRegExp($output, "Estado de conexi.n:\h+(\w+)", 3)
_ArrayDisplay($status)

image.png.1dec1487b8b13c951abfdcf63a66e816.png

Link to comment
Share on other sites

Switch your source file to Unicode (UTF8) under SciTE and also check wich version of AutoIt you're running. This works for me:

Local $s = "Estado de conexión:        Conectado "
ConsoleWrite(StringRegExp($s, "Estado de conexión:\h+(\w+)", 3)[0] & @LF)

 

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

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