Exodious
09-02-2003, 04:45 PM
Hiya, should be simple, but can't seem to work out how to match a square bracket
Take this as a string, for example:
sundries_matrix[2] = "Sundry 3";
current equals the above string
if(match(current, "sundries_list.2. = \"Sundry 3\";") != 0) returns 1 which is fine
But I need to match based on the square brackets so
if(match(current, "sundries_list\[2\] = \"Sundry 3\";") != 0) returns 0
I just cannot seem to get nawk to recognise square bracket as a character instead of a special something or other, is there any chance I can do it? what does nawk see [ or ] as?
The reason I need the brackets in, is so I can use substr to cut out the characters (numbers) between the open and close brackets to allow for infinite growth
Thx for any ideas, or god forbid, the answer :D
Take this as a string, for example:
sundries_matrix[2] = "Sundry 3";
current equals the above string
if(match(current, "sundries_list.2. = \"Sundry 3\";") != 0) returns 1 which is fine
But I need to match based on the square brackets so
if(match(current, "sundries_list\[2\] = \"Sundry 3\";") != 0) returns 0
I just cannot seem to get nawk to recognise square bracket as a character instead of a special something or other, is there any chance I can do it? what does nawk see [ or ] as?
The reason I need the brackets in, is so I can use substr to cut out the characters (numbers) between the open and close brackets to allow for infinite growth
Thx for any ideas, or god forbid, the answer :D