string from string

scoob8254

Registered User.
Local time
Today, 08:51
Joined
Mar 2, 2008
Messages
76
hi,

i know this has been covered many times but im completely stuck, im postive its something simple but after a few hrs searching this forum and the web i cant resolve it

to cut a very long story short, i have a some code that runs thru log files, and strips out the info im after.

all is well except from getting 1 bit of info from a string

heres an example string

L 01/03/2010 - 20:34:00: "dragon_mk<80><STEAM_0:1:9999999999><>" STEAM USERID validated

im looking at getting the user alias part of the string which in this example is dragon_mk,

i was going to use mid to get the info as the log always follows a set format so the start point for mid would always be 27,

i was going to use some code with InStrRev to find the 3rd < from the right to enable to work out the length of the alias, but my code keeps returning null, even a basic instrrev looking for the first < from the right returns null. and i cant search for the first < from the left as its possible the alias could contain < as alias's are allowed to use any char even spec characters.

is this because < is a special char ?

is their another way to achieve what i want

i cant simply count from the right of the string as the <80> part and the <STEAM_0:1:9999999999> part can be different lengths depending on the users details..

any help appreciated

scoobs
 
Is their ID always before the first < ?
 
hi

if u mean id as in the alias, then no, their alias can sometimes contain a <

scoobs
 
Another possible solution would be to use a regular expression (regex)

Here is a previous post on the subject:

regex validation

Hope this helps ...
 
hi looking at the regex, seems a bit heavy for what im wanting, wouldnt the string have to be a set pattern to use regex, which im unsure how this would work as the alias can be upto about 50 characters long and may contain numerical, alphabetical and special characters, basicaly theirs no restrictions on the alias apart from its length,

for instance it would be even possible to have for example

<<<><><><><><>><<>^*@~<<<<80><STEAM_0:1:9999999999><>" STEAM USERID validated

as a alias, so <<<><><><><><>><<>^*@~<<< would be the alias

why i wanted to count < from the right as these remain constant if counted from right :(, ie the alias will always be between char 27 and the 3rd < from the right

scoobs
 
OK....

This is really ugly, but it worked for me I had to do this in 4 parts.....

Here is the sql... Table 5 is the table name and test is the name of the field that I have your examples in...

Get Ready... its ugly
Code:
SELECT Table5.Test, Right([expr1],Len([expr1])-(InStr([expr1],Chr(34)))) AS Expr4, Left([expr2],(InStrRev([expr2],Chr(60))-1)) AS Expr1, Left([expr3],(InStrRev([expr3],Chr(60))-1)) AS expr2, Left([test],(InStrRev([test],Chr(60))-1)) AS Expr3
FROM Table5;
 
This is my Mid that worked, field is F1 and starting position is 5 as opposed to 27 to save on typing.
Basically you nest the InstrRev moving the starting position.

Mid([f1],5,InStrRev([f1],"<",InStrRev([f1],"<",InStrRev([f1],"<")-1)-1)-5)


Brian
 
This is my Mid that worked, field is F1 and starting position is 5 as opposed to 27 to save on typing.
Basically you nest the InstrRev moving the starting position.

Mid([f1],5,InStrRev([f1],"<",InStrRev([f1],"<",InStrRev([f1],"<")-1)-1)-5)


Brian


Nice one. Much cleaner than mine! Knew it could be done another way, just couldn't get my mid attempts to work correctly!
 

Users who are viewing this thread

Back
Top Bottom