Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 11:58 07 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Position of a substring

Author Message
Herry

Senior Member

Joined: 31/05/2014
Location: Australia
Posts: 261
Posted: 10:51am 09 Jul 2016
Copy link to clipboard 
Print this post

I want to find the position of a substring (say 'a') in a string (say 'Marvel').
Need to find the MMBasic syntax for INSTR or POS or something like that. Syntax like: Position = ("Marvel","a"), so that position here yields 2.

Or even starting the search from some other place than the start of the string, something like Position = (String, Start, Instring)
Senior?!  Whatever it says, I'm a complete and utter beginner...
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1667
Posted: 11:11am 09 Jul 2016
Copy link to clipboard 
Print this post

Page 75 of the manual.

[Quote]INSTR( [start-position,] stringsearched$,
string-pattern$ )

Returns the position at which 'string-pattern$' occurs in 'string-searched$',
beginning at 'start-position'.
Both the position returned and 'start-position' use 1 for the first character, 2
for the second, etc. The function returns zero if 'string-pattern$' is not found.
[/quote]

The Manual can be found here

Cheers
 
Herry

Senior Member

Joined: 31/05/2014
Location: Australia
Posts: 261
Posted: 11:31am 09 Jul 2016
Copy link to clipboard 
Print this post

Many thanks. Just what I wanted. Couldn't find it in my manual (must be way out of date)... Or else I am!
Senior?!  Whatever it says, I'm a complete and utter beginner...
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025