• ### Similar Content

• Hi,
I have a string like this :
Global \$Msga = "urrent directory is /send.  (Submission of file with log number 29381077284 is confirmed)";
I want to extract the number 29381077284  from the string. I did StringSplit to split based on "(" and then use space to reach there, But it's not a good choice.
Can anyone help me with regular expression to find the number from String using AutoIT. TIA
• By Chimp
Hello
if I have a string like in the example below,
is there a regular expression that can surround any "string" (and only strings) within quotes?.
The whole input string is a "constructor" to populate an array so even if an element contains more words (a phrase) it should be considered as a single word (Elton John should be considered a single word and as that quoted as "Elton John")
for example
the following string
[[Elton John,Peter,Sally,123],[1 one 1,2,3,4 four 4]] should be transformed to this other string
[["Elton John","Peter","Sally",123],["1 one 1",2,3,"4 four 4"]] Thanks for your help
Here a small script to use as "guinea pig"
#include <Array.au3> Local \$aArray = [["Elton John", "Peter", "Sally", 123],["one 1", 2, 3, "4 four 4"]] MsgBox(0, "Result", _Array2Json(\$aArray)) Func _Array2Json(\$aArray) If (Not IsArray(\$aArray)) Or (UBound(\$aArray, 0) > 2) Then Return SetError(1, 0, '') Local \$sOpening, \$sClosing If UBound(\$aArray, 0) = 1 Then \$sOpening = '[' \$sClosing = ']' Else \$sOpening = '[[' \$sClosing = ']]' EndIf \$sOutpt = \$sOpening & _ArrayToString(\$aArray, ",", -1, -1, "],[") & \$sClosing ; \$sOutpt = ???? how to quote strings ???? Return \$sOutpt EndFunc ;==>_Array2Json

• Inspired by PHP's preg_split.
Split string by a regular expression.
Also supports the same flags as the PHP equivalent.
v1.0.1

Example:
#include "StringRegExpSplit.au3" StringRegExpSplit('splitCamelCaseWords', '(?<=\w)(?=[A-Z])') ; ['split', 'Camel', 'Case', 'Words']

• Hello, I'm trying to match the second to last line of this:
foo C:\ foobar foobar x C:\temp\dir Last line with chars Here's my code:
\$test = 'foo' & @CRLF \$test &= 'C:\' & @CRLF \$test &= 'foobar' & @CRLF \$test &= 'hello' & @CRLF \$test &= 'C:\temp\dir' & @CRLF \$test &= 'Last line with chars' & @CRLF \$test &= @CRLF \$test &= @CRLF \$result = StringRegExp(\$test, '(?m)^C:\\.*\$Last.*') MsgBox(0, '', \$result) I'm trying to match line "C:\temp\dir".  Anyone have any ideas?
• By therks
I'm looking for a regex genius, cus I'm stumped when it comes to assertions.
So what I have now, is this regular expression: ([^|=]+)=([^|]+)
It takes a string (user input) of keys=values separated by pipes (ie: "param=value|param=value") and splits them into an array.
Example:
\$vParamData = 'example=value|fruit=apple|phrase=Hello world' \$aRegEx = StringRegExp(\$vParamData, '([^|=]+)=([^|]+)', 3) ; Result ; [0] => example ; [1] => value ; [2] => fruit ; [3] => apple ; [4] => phrase ; [5] => Hello world So that's working fine, but I'm wondering if there's also a way I could have this capture escaped pipes instead of splitting by them.
ie:
\$vParamData = 'pipe test=this \| is a pipe|example=value' \$aRegEx = StringRegExp(\$vParamData, '([^|=]+)=([^|]+)', 3) ; I'm getting this: ; [0] => pipe test ; [1] => this \ ; [2] => example ; [3] => value ; But I'd like a result like this: ; [0] => pipe test ; [1] => this \| is a pipe ; [2] => example ; [3] => value Is there some pattern that would accomplish this, or am I better off parsing it some other way?
×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...