Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Programming Talk / Delphi - Search A String And Return A Character Pos Help Please

Author
Message
The Lone Programmer
22
Years of Service
User Offline
Joined: 29th Jan 2003
Location: California, USA
Posted: 9th Jul 2005 04:20
Hey,

I just recently discovered the:
LastDelimiter('Search', 'Src')

Command and it does its job perfectly.

Is there a FirstDelimter command or something. I want to be able to type in:
'*/+-'
and have it find the position of the first occurance of one of those characters.

I could type:
LastDelimiter('*/+-', String)
and it will give me the last occurrance of one of those characters in my string.

What command(s) will return the position of the first character from a list of them?

Please help me out

Thanks,
The Lone Programmer

"Is The Juice Worth The Squeeze"
-The Girl Next Door
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 9th Jul 2005 05:21
position - (length of sought-1)

no?

DBP Plugins Latest: MSAccess, SQLServer - July 2005
The Lone Programmer
22
Years of Service
User Offline
Joined: 29th Jan 2003
Location: California, USA
Posted: 9th Jul 2005 07:36
The
Pos(SubStr, SrcStr)
will not find the first occurance of the set of characters and stop. And you cannot use a set of characters. It will only search for 1 designated character and stop.

Say I got this:
String := '123143567'

Now say I do this:
Value := Pos('3', String)

Its going to give me the position of the first 3. Now say that is what I want only if the string doesnt contain any other of the characters I'm looking for.

The reason for this is because of a Calculater Type program I want to build. The Calculator must follow the Order of Operations (PEMDAS).

Say it searches and finds a * symbol. I can't use the symbol until im sure that the character before and after it don't contain anything but numbers. The LastDelimiter command will work for finding if it works on the left hand side of the symbol but I don't have anything for the right hand side.

I would just do a:
TempStr := RightStr(String, Length(String)-Pos(LastDelimiter('*/+-', String), String))

Since LastDelimiter is returning the position of the last character occurance then there will for sure be no symbols in that string if i use a right string.

Not so easy going left.


If you have any suggestions let me know.

Thanks,
The Lone Programmer

"Is The Juice Worth The Squeeze"
-The Girl Next Door
empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 9th Jul 2005 09:25
You could use IsDelimter to create your own FirstDelimiter function.




Play Nice! Play Basic! Version 1.073

Login to post a reply

Server time is: 2025-06-04 18:02:20
Your offset time is: 2025-06-04 18:02:20