Sign in to follow this  
Followers 0
Kovitt

Quick StringRegExp

8 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

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

Thank you for the response!!

So it would be

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Thanks your a huge help! :)

Share this post


Link to post
Share on other sites

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

How would I modify this to not include the + or - ?

Thanks

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#include <Array.au3>

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

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

_ArrayDisplay($re)

Perfect! Thanks!!

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