Forum: Ruby Finding pattern in strings

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
De4b72fae29750fb1109f481d5649cad?d=identicon&s=25 Srinivas reddy Guda (srinuguda)
on 2008-10-13 08:32
Hello Friends,

How to find the pattern in strings.

Example: In string "MATHEMATICS", i want to know the first occurrence of
"MAT".

Is there any standard function is available or we have to write our own
code for this?

I am looking like function in oracle INSTR.

Thanks in Advance,
Srinivas.
6087a044557d6b59ab52e7dd20f94da8?d=identicon&s=25 Peña, Botp (Guest)
on 2008-10-13 08:42
(Received via mailing list)
From: Srinivas reddy Guda [mailto:gsr@fast-forward.com.sg]
# How to find the pattern in strings.

find it..

http://www.ruby-doc.org/core/classes/String.html

qri string.=~

qri string.index
De4b72fae29750fb1109f481d5649cad?d=identicon&s=25 Srinivas reddy Guda (srinuguda)
on 2008-10-13 08:54
Peña, Botp wrote:
> From: Srinivas reddy Guda [mailto:gsr@fast-forward.com.sg]
> # How to find the pattern in strings.
>
> find it..
>
> http://www.ruby-doc.org/core/classes/String.html
>
> qri string.=~
>
> qri string.index

Thanks. index will fulfill by requirement.
This topic is locked and can not be replied to.