 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Firewolf91
Joined: 19 Oct 2007 Posts: 134 Location: PA
|
Posted: Tue Mar 04, 2008 8:20 pm Post subject: expressions with a semicolon ; [Solved] |
|
|
I'm trying to search a string for a semicolon and the syntax i'm using obviously doesn't work.
here's the INCORRECT code:
| Code: | IfInString, emailadd,;
{
epos := InStr(emailadd,`;,CaseSensitive = false, StartingPos = 1)
eLength := StrLen(emailadd) - epos
StringTrimRight, emailadd, emailadd, %eLength%
MsgBox, It got thru! %epos% is epos. eLength is %eLength% and %emailadd% is not trimmed again. arrr
} |
using epos := InStr(... gives me an error that the "leftmost character is illegal in an expression." (speaking of the semicolon)
if i remove the : (i.e. epos = InStr), the expression returns the exact text as such an expression should (without the ":").
the text i'm trying to cut down will appear something like this:
it should use the semicolon as the delimiter by finding it's position, then trimming the right side off, leaving just the first email address.
what syntax am i doing wrong...or better yet, how am i supposed to correctly search for a semicolon so i can split the email addresses?
Last edited by Firewolf91 on Thu Mar 06, 2008 1:56 pm; edited 1 time in total |
|
| Back to top |
|
 |
Kellianjaxon
Joined: 04 Jan 2008 Posts: 102
|
Posted: Tue Mar 04, 2008 8:38 pm Post subject: |
|
|
You were missing quotes from around semicolon in InStr. Using literal strings in expressions always requires quotes. I also modified the last parameter of StringTrimRight to remove the semicolon as well.
| Code: | emailadd = email123@home.com; email456@home.com
IfInString, emailadd,;
{
epos := InStr(emailadd,";",CaseSensitive = false, StartingPos = 1)
eLength := StrLen(emailadd) - epos
StringTrimRight, emailadd, emailadd, % eLength + 1
MsgBox, It got thru! %epos% is epos. eLength is %eLength% and %emailadd% is not trimmed again. arrr
} |
|
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 8688
|
Posted: Tue Mar 04, 2008 8:40 pm Post subject: |
|
|
| Code: | Str := "email123@home.com; email456@home.com"
If ( ePos := InStr( Str, ";" ) )
NewStr := SubStr(Str,1, ePos-1 )
MsgBox, % NewStr |
Edit:
| Code: | Str := "email123@home.com; email456@home.com"
NewStr := ( ePos := InStr( Str, ";" ) ) ? SubStr(Str,1, ePos-1 ) : ""
MsgBox, % NewStr |
|
|
| Back to top |
|
 |
Firewolf91
Joined: 19 Oct 2007 Posts: 134 Location: PA
|
Posted: Tue Mar 04, 2008 8:59 pm Post subject: |
|
|
thanks both of you...brain is fried from 3 people in my office asking me to do random stuff non-stop, so i've had like 1 min(at the most) at any given time to "think" or at least collect my thoughts before someone else spoke up. >,<
what day is it? tue? arrrrrr this week is so long!
but really, i should have remembered the quotes
and thanks kell with removing the ; itself from the result. i figured i was probably going to be one place off. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|