Jump to content

Quick StringRegExp


Recommended Posts

Hello,

How would I write a StringRegExp that looks for this between a + and a s or a - and an s.

I first tried with _StringBetween() but I need it to scan a whole document..

the output it needs to search through looks like:

Analyzing TESTCOMPUTER (1 of 1)...

resolving referer 59.64.64.63 (1 of 1)...

TESTCOMPUTER [15.3.6.452]:

ICMP: 0ms delay.

NTP: +17.5781250s offset from local clock

RefID: 'LOCL' [59.64.64.63 ]

It needs to find whats after NTP: which in some cases could be negative..

Any Suggestions?

What I have tried is:

StringRegExp($times,'([+]{1},[:digit]{1,},[.]{1},[:digit]{1,}?:)

but this wont do + or -

Thanks :D

Edited by Kovitt
Link to comment
Share on other sites

  • Moderators

"NTP:\s*([\+-].+?)s"

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

Thank you for the response!!

So it would be

StringRegExp($times,'(NTP:\s*([\+-].+?)s)?:') ?

$a_sre = StringRegExp($times, "NTP:\s*([\+-].+?)s", 3)

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

#include <Array.au3>

$string = 'NTP: +17.5781250s offset from local clock'

$re = StringRegExp($string, 'NTP:\s*[\+-](.+?)s', 3)

_ArrayDisplay($re)

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

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