mysql - Get At Least X Characters Before Keyword PHP -


i'm making small search system using php , mysql.

i have this:

preg_match('#(.{75}' . $s . '.{75})#s', $b, $match); if (isset($match[1])) {    return preg_replace('#(.+?)' . $s . '(.+)#s', '$1<span><b>' . $s . '</b>     </span>$2', $match[1]); } else {     return 'error'; } 

this job of getting first appearance of keyword(s) , getting 75 characters before , after it. problem if there less 75 characters, not go through. pretty new regex , got above code , it's not mine.

if understood correctly want match characters n number 75, if case have is: {10,75} 10 n number(lower) limit in regex.

'#(.{10,75}' . $s . '.{10,75})#s' 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -