Sign in to follow this  
Followers 0
sejje

Extraction from a string

5 posts in this topic

#1 ·  Posted (edited)

I have a complex (group of) string that I need to extract information from, and I'm not sure the best way and/or the syntax.

The string looks like this:

AB77777 xyzxyzxyz setinstone( 666666666), cbacbacbacbacbacba

Now, almost the entire string is variable. The only constant parts are "AB", "setinstone (" and "), "

The rest (in blue) is different every time I handle the string (these are filenames, for the record). Also, the length of the variable portions is not constant. So 77777 could also be 7777777777777.

I need to extract the variable parts (I can probably do with one example, currently I'm trying to extract 66666666 from the string).

My idea would be to find the location of each parentheses in the string, and then use Mid to extract all the values in-between them, but 1) I'm not sure this is the best way and 2) I cannot find a function to return the location of a searched string withing another string.

Any help would be greatly appreciated. I have several new wrinkles from but a few hours of mulling over this one.

Edited by sejje

Share this post


Link to post
Share on other sites



Since there are a few constants "_StringBetween" will work, else i would have used "stringregexp"


UDF:Crypter a file encrypt / decrypt tool with no need to remember a password again. Based on Caesar cipher using entire ASCII Table.Script's: PixelSearch Helper, quick and simple way to create a PixelSeach.Chatserver - simplified, not so complicated multi-socket server.AutoIT - Firewall, simple example on howto create a firewall with AutoIt.

Share this post


Link to post
Share on other sites

Since there are a few constants "_StringBetween" will work, else i would have used "stringregexp"

I saw a reference to _StringBetween before, but it is not in the function list. Am I missing something? Any link readily available?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Is it a sub-function of something else? Does the data have to be an array or something? It's returning an error when I try it on my string. (Unknown function name)

Edited by sejje

Share this post


Link to post
Share on other sites

you need to include "string.au3"

From help file:

_StringBetween 
--------------------------------------------------------------------------------

Returns the string between the start search string and the end search string.


#include <String.au3>
_StringBetween ( $sString, $sStart, $sEnd [, $vCase [, $iSRE ]] )


 

Parameters

$sString The string to search. 
$sStart The beginning of the string to find 
$sEnd The end of the string to find 
$vCase Optional: Case sensitive search. Default or -1 is not Case sensitive else Case sensitive. 
$iSRE Optional: Toggle for regular string manipulation or StringRegExp search. Default is regular string manipulation. 

 

Return Value

Success: A 0 based $array[0] contains the first found string. 
Failure: 0 
@Error: 1 = No inbetween string found. 

 

Remarks

None.


 

Related

None. 
 

Example

#include <String.au3>
#include <array.au3>
$aArray1 = _StringBetween('[18][20][3][5][500][60]', '[', ']');Not using SRE
_ArrayDisplay($aArray1, 'Default Search')
$aArray2 = _StringBetween('[18][20][3][5][500][60]', '\[', '\]', -1, 1);Using SRE
_ArrayDisplay($aArray2, 'StringRegExp Search')

UDF:Crypter a file encrypt / decrypt tool with no need to remember a password again. Based on Caesar cipher using entire ASCII Table.Script's: PixelSearch Helper, quick and simple way to create a PixelSeach.Chatserver - simplified, not so complicated multi-socket server.AutoIT - Firewall, simple example on howto create a firewall with AutoIt.

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