in reply to Re^2: compare individual string with complete array
in thread compare individual string with complete array
Hello again rohan_532,
You are mixing many questions and issues here.
Having a case sensitive string is something different that comparing with a regex with numbers. So take a step backwards and analyze it.
If you have an upper case string and you want to convert it to a lower case you can simply use lc or the opposite assume that you have a lower case string and you want to convert to upper case uc. Or even igf you manage to split the string into pieces and you want to make only the first letter of the string upper case ucfirst.
Regarding the regex part of your question:
#!usr/bin/perl use strict; use warnings; my @steps_name = ("1-2 Steps", "5-7 Steps", "8-10 Steps", "11-15 Steps +"); foreach my $element (@steps_name) { print "Matched with ".$element."\n" if ($element =~ /[0-9]-[0- +9]/); } __END__ $ perl test.pl Matched with 1-2 Steps Matched with 5-7 Steps Matched with 8-10 Steps Matched with 11-15 Steps
As you can see this will match with all elements, so you need to be a bit more specific on what you want to compare against. For example 1-2 Steps only, or multiple choices?
Again I am looking forward to update your question with more details.
Update: Have you read the answers that marinersk and AnomalousMonk have already provided you on your previous question regex for case insensitive? I looks like they have already addressed your problem.
Hope this is more clear now, programming gives you infinite possibilities, you have to tell us exactly what is the desired output.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: compare individual string with complete array
by rohan_532 (Initiate) on May 31, 2017 at 11:38 UTC | |
by thanos1983 (Parson) on May 31, 2017 at 12:49 UTC | |
by rohan_532 (Initiate) on Jun 01, 2017 at 03:34 UTC | |
by AnomalousMonk (Archbishop) on Jun 01, 2017 at 06:47 UTC | |
by thanos1983 (Parson) on Jun 01, 2017 at 08:14 UTC | |
by rohan_532 (Initiate) on Jun 02, 2017 at 04:50 UTC |