Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Regular Expressions in shell scripts <yawn> Post 6370 by Perderabo on Tuesday 4th of September 2001 02:29:45 PM
Old 09-04-2001
In ksh you can use patterns...
Code:
if [[ $1 = +([0-9]).+([0-9]).+([0-9]).+([0-9]) ]] ; then
   echo $1 is an ip address
else
   echo $1 is not an ip address
fi

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

using regular expressions in c shell control structure

i cant get around using regular expressions in if/else statements. it simply doesnt give me the right results. i've tried using switch/case but that is just as sh!tty as well. (pardon my french but im getting frustrated with c shell..only reason why im writing in it is because it's a hwk... (3 Replies)
Discussion started by: ballazrus
3 Replies

2. Shell Programming and Scripting

Regular Expressions

How can i create a regular expression which can detect a new line charcter followed by a special character say * and replace these both by a string of zero length? Eg: Input File san.txt hello hi ... (6 Replies)
Discussion started by: sandeep_hi
6 Replies

3. Shell Programming and Scripting

Help with regular expressions

I have following content in the file CancelPolicyMultiLingual3=U|PC3|EN RestaurantInfoCode1=U|restID1|1 ..... I am trying to use following matching extression \|(+) to get this PC3|EN restID1|1 Obviously it does not work. Any ideas? (13 Replies)
Discussion started by: arushunter
13 Replies

4. UNIX for Dummies Questions & Answers

regular expressions

Hi Gurus, I need help with regular expressions. I want to create a regular expression which will take only alpha-numeric characters for 7 characters long and will throw out an error if longer than that. i tried various combinations but couldn't get it, please help me how to get it guys. ... (2 Replies)
Discussion started by: ragha81
2 Replies

5. UNIX for Dummies Questions & Answers

Execute a shell script using regular expressions

I am have a configuration script that my shell script uses. There is a regular expression defined for the input file. How do execute the shell script and pass the name of the input file using a regular expression. I would greatly appreciate some help. If you could point my to a website that... (1 Reply)
Discussion started by: supergirl3954
1 Replies

6. UNIX for Advanced & Expert Users

regular expressions

I have a flat file with the following drug names Nutropin AQ 20mg PEN Cart 2ml Norditropin Cart 15mg/1.5ml I have to extract digits that are before mg i.e 20 and 15 ; how to do this using regular expressions Thanks ram (1 Reply)
Discussion started by: ramky79
1 Replies

7. UNIX for Dummies Questions & Answers

Regular expressions

In regular expressions with grep(or egrep), ^ works if we want something in starting of line..but what if we write ^^^ or ^ for pattern matching??..Hope u all r familiar with regular expressions for pattern matching.. (1 Reply)
Discussion started by: aadi_uni
1 Replies

8. Shell Programming and Scripting

Regular Expressions

#!/usr/bin/perl $word = "one last challenge"; if ( $word =~ /^(\w+).*\s(\w+)$/ ) { print "$1"; print "\n"; print "$2"; } The output shows that "$1" is with result one and "$2" is with result challenge. I am confused about how this pattern match expression works step by step. I... (8 Replies)
Discussion started by: DavidHe
8 Replies

9. Shell Programming and Scripting

Regular Expressions

what elements does " /^/ " match? I did the test which indicates that it matches single lowercase character like 'a','b' etc. and '1','2' etc. But I really confused with that. Because, "/^abc/" matches strings like "abcedf" or "abcddddee". So, what does caret ^ really mean? Any response... (2 Replies)
Discussion started by: DavidHe
2 Replies

10. Shell Programming and Scripting

Regular Expressions in K Shell Script

I need to write a K shell script to find full file names , line numbers and lines which have words meeting either of following 2 criterias - 1)words which are 6 to 8 character long and alphanumeric. 2)Minimum 8 characters, one upper case, one lower case letter, one of the special characters... (1 Reply)
Discussion started by: Rajpreet1985
1 Replies
DATEFMT_SET_LENIENT(3)							 1						    DATEFMT_SET_LENIENT(3)

IntlDateFormatter::setLenient - Set the leniency of the parser

	Object oriented style

SYNOPSIS
public bool IntlDateFormatter::setLenient (bool $lenient) DESCRIPTION
Procedural style bool datefmt_set_lenient (IntlDateFormatter $fmt, bool $lenient) Define if the parser is strict or lenient in interpreting inputs that do not match the pattern exactly. Enabling lenient parsing allows the parser to accept otherwise flawed date or time patterns, parsing as much as possible to obtain a value. Extra space, unrecognized tokens, or invalid values ("February 30th") are not accepted. PARAMETERS
o $fmt - The formatter resource o $lenient - Sets whether the parser is lenient or not, default is TRUE (lenient). RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 datefmt_set_lenient(3) example <?php $fmt = datefmt_create( 'en_US', IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/Los_Angeles', IntlDateFormatter::GREGORIAN, 'dd/MM/yyyy' ); echo 'lenient of the formatter is : '; if ($fmt->isLenient()) { echo 'TRUE'; } else { echo 'FALSE'; } datefmt_parse($fmt, '35/13/1971'); echo " Trying to do parse('35/13/1971'). Result is : " . datefmt_parse($fmt, '35/13/1971'); if (intl_get_error_code() != 0) { echo " Error_msg is : " . intl_get_error_message(); echo " Error_code is : " . intl_get_error_code(); } datefmt_set_lenient($fmt, false); echo " Now lenient of the formatter is : "; if ($fmt->isLenient()) { echo 'TRUE'; } else { echo 'FALSE'; } datefmt_parse($fmt, '35/13/1971'); echo " Trying to do parse('35/13/1971'). Result is : " . datefmt_parse($fmt, '35/13/1971'); if (intl_get_error_code() != 0) { echo " Error_msg is : ".intl_get_error_message(); echo " Error_code is : ".intl_get_error_code(); } ?> Example #2 OO example <?php $fmt = new IntlDateFormatter( 'en_US', IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/Los_Angeles', IntlDateFormatter::GREGORIAN, 'dd/MM/yyyy' ); echo 'lenient of the formatter is : '; if ($fmt->isLenient()) { echo 'TRUE'; } else { echo 'FALSE'; } $fmt->parse('35/13/1971'); echo " Trying to do parse('35/13/1971'). Result is : " . $fmt->parse('35/13/1971'); if (intl_get_error_code() != 0) { echo " Error_msg is : " . intl_get_error_message(); echo " Error_code is : " . intl_get_error_code(); } $fmt->setLenient(FALSE); echo " Now lenient of the formatter is : "; if ($fmt->isLenient()) { echo 'TRUE'; } else { echo 'FALSE'; } $fmt->parse('35/13/1971'); echo " Trying to do parse('35/13/1971'). Result is : " . $fmt->parse('35/13/1971'); if (intl_get_error_code() != 0) { echo " Error_msg is : " . intl_get_error_message(); echo " Error_code is : " . intl_get_error_code(); } ?> The above example will output: lenient of the formatter is : TRUE Trying to do parse('35/13/1971'). Result is : 66038400 Now lenient of the formatter is : FALSE Trying to do parse('35/13/1971'). Result is : Error_msg is : Date parsing failed: U_PARSE_ERROR Error_code is : 9 SEE ALSO
datefmt_is_lenient(3), datefmt_create(3). PHP Documentation Group DATEFMT_SET_LENIENT(3)
All times are GMT -4. The time now is 03:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy