Jump to content

Recommended Posts

Posted

Hi everybody!

I'm trying to find a way to extract ALL strings between "@"-chars from

the following (example) string:

"test @sirname@, @username@ - @computername@ - test"

This should be the result:

1. "sirname"

2. ", "

3. "username"

4. " - "

5. "computername"

I tried to figure out by myself using StringRegExp() or _StringBetween() - without luck... :-(

Any ideas?

Greets,

-supersonic.

Posted

Hi everybody!

I'm trying to find a way to extract ALL strings between "@"-chars from

the following (example) string:

"test @sirname@, @username@ - @computername@ - test"

This should be the result:

1. "sirname"

2. ", "

3. "username"

4. " - "

5. "computername"

I tried to figure out by myself using StringRegExp() or _StringBetween() - without luck... :-(

Any ideas?

Greets,

-supersonic.

#include <array.au3>

$str1 = "test @sirname@, @username@ - @computername@ - test"
$res = StringRegExp($str1,"@(\w*?)@",3)
if IsArray($res) then
 _ArrayDisplay($res)
EndIf
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Posted (edited)

This works, but needs testing with real data.

#include <Array.au3>
$sString = "test @sirname@, @username@ - @computername@ - test"
$aArray = StringRegExp($sString, '(?U)(?<=@)(\S*)@', 3)
_ArrayDisplay($aArray)
edit: remove unnecessary .*

Edited by picaxe
  • 2 weeks later...

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
×
×
  • Create New...