Jump to content
Sign in to follow this  
modernes

String Parsing

Recommended Posts

modernes

Hi,

I am trying to parse a string with data as follows:

xxxxxxxx

xxxxxxxx

xxxxxxxx

Name: Joe Blow

xxxxxxxx

xxxxxxxx

(where the x's represent random data)

What would be a good way to use to extract the name from the string?

Share this post


Link to post
Share on other sites
/dev/null

What would be a good way to use to extract the name from the string?

StringSplit().

EDIT: Oh, wait. all the lines are ONE string?

Cheers

Kurt

Edited by /dev/null

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites
Paulie

If you know how much of the random data there is on either side of the important stuff

Look at the "StringTrim*"Functions

If you don't know this Look at "StringRegExp"

Edited by Paulie

Share this post


Link to post
Share on other sites
xcal

Just use _FileReadToArray(), run the array through a loop with an If StringInStr(),check for 'Name:', and do something if there's a match.

edit - badly formed sentence. ><

Edited by xcal

Share this post


Link to post
Share on other sites
modernes

StringSplit().

EDIT: Oh, wait. all the lines are ONE string?

Cheers

Kurt

Yes, the whole thing is ONE string - would there be a way to read starting from "Name:" all the way to carriage return?

Share this post


Link to post
Share on other sites
SmOke_N

Yes, the whole thing is ONE string - would there be a way to read starting from "Name:" all the way to carriage return?

Beta 3.2.1.12 ... Look at _StringBetween() and the StringRegExp option.

_StringBetween($sString, 'Name\:', '\r\n', -1, 1)oÝ÷ Ù8Z¶h Ü(®AÓ©¦ÈZvØ^  Åm§$ÁªÝ°Gb·b¶nÞv¬mÂäÊj{kÊØ^±ç(¸§jبËh±ç¢~Ø^ÉÚºÚ"µÍÔÝ[Ð]ÙY[  ÌÍÜÔÝ[Ë   ÌÎNÓ[YIÌLÎÌÎNË  ÌÎNÉÌLÜÌÎNËLKJoÝ÷ Ù«­¢+Ù}MÑÉ¥¹   Ñݸ ÀÌØíÍMÑÉ¥¹°Ìäí9µÀäÈìèÌäì°ÌäìÀäÈí¸Ìäì°´Ä°ÄoÝ÷ Ù«­¢+Ù}MÑÉ¥¹  Ñݸ ÀÌØíÍMÑÉ¥¹°Ìäí9µèÌäì°
I1¤oÝ÷ Ù«­¢+Ù}MÑÉ¥¹ Ñݸ ÀÌØíÍMÑÉ¥¹°Ìäí9µÀäÈìèÌäì°
HoÝ÷ Ù«­¢+Ù}MÑÉ¥¹    Ñݸ ÀÌØíÍMÑÉ¥¹°Ìäí9µÀäÈìèÌäì°1
Edited by SmOke_N

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
mikehunt114

This should return "Name: Joe Blow", and everything after it into $temp, if that helps.

$string = clipget()
$temp = StringInStr($string, "Name: Joe Blow")
$temp = StringMid($string, $temp)

IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]

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  

×