laanes Posted June 10, 2011 Share Posted June 10, 2011 Can anyone help me to figure out a pattern that matches all the underlined zn's ? mnzertainlyzn cznar availznable in zn finznish zn / zn, zn/zn zn umzn:) I tried this: '#\s?zn\s?#' This is close to what i expect but matches also the ones contained inside words which i don't want. Link to comment https://forums.phpfreaks.com/topic/239020-pattern-to-match-zn-not-contained-in-a-word/ Share on other sites More sharing options...
fugix Posted June 10, 2011 Share Posted June 10, 2011 for that line of text there you would want /\/?|\s?[zn]/ Edit: revised the code, and of course you can use whatever delimiters you'd like Link to comment https://forums.phpfreaks.com/topic/239020-pattern-to-match-zn-not-contained-in-a-word/#findComment-1228118 Share on other sites More sharing options...
requinix Posted June 10, 2011 Share Posted June 10, 2011 Not quite right. Using \b as a word boundary, /\bzn/ Link to comment https://forums.phpfreaks.com/topic/239020-pattern-to-match-zn-not-contained-in-a-word/#findComment-1228124 Share on other sites More sharing options...
fugix Posted June 10, 2011 Share Posted June 10, 2011 Not quite right. Using \b as a word boundary, /\bzn/ Nice, didn't even think of using a word boundary for some reason. Short and sweet solution Link to comment https://forums.phpfreaks.com/topic/239020-pattern-to-match-zn-not-contained-in-a-word/#findComment-1228133 Share on other sites More sharing options...
JAY6390 Posted June 11, 2011 Share Posted June 11, 2011 I'm guessing you'd want it to not match znasdsfs but the above will, so using a second word boundary after it will solve it /\bzn\b/ Link to comment https://forums.phpfreaks.com/topic/239020-pattern-to-match-zn-not-contained-in-a-word/#findComment-1228149 Share on other sites More sharing options...
laanes Posted June 11, 2011 Author Share Posted June 11, 2011 Thanks guys! Now my script is singing and dancing. You are the best! Greetings, laanes Link to comment https://forums.phpfreaks.com/topic/239020-pattern-to-match-zn-not-contained-in-a-word/#findComment-1228274 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.