TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
alec
NA
86
57.5k
String[] index number from regex search
Sep 5 2011 9:32 AM
I have a string[] that I search using regex and it returns a list of elements in my string[] that match what I searched for using regex. I would like to find the index number of the elements that are returned.
example:
string[] StringArray = {"aaa","bbb","ccc","ddd","eee"};
string find = "bbb";
List<string> FoundList = new List<string>();
foreach (string Block in StringArray)
{
if (System.Text.RegularExpressions.Regex.IsMatch(Block, find,
System.Text.RegularExpressions.RegexOptions.IgnoreCase))
{
FoundList.Add(Block);
}
else
{
//do nothing
}
}
string[] FoundArray = FoundList.ToArray();
it will create FoundArray = {"bbb"} and I wish to find int i such that
StringArray[i] = FoundArray[0]
is true and for senarios where FoundArray has multiple entries I plan to loop it. Any help would be much appreciated.
Reply
Answers (
5
)
How to retreive the emailaddress from document and placed in textbox
Dynamically Convert XML(With custom tages) in to HTML