ARITABACAN Posted July 21, 2017 Share Posted July 21, 2017 I have two questions, first <?php $text = "a iKo SaioT eeee"; $fonts = "a|i|u|e|o"; $newText = preg_replace("#([$fonts].+?(?=[^$fonts![:space:]]))#us", '<b>$1</b>', $text); echo $newText; ?> Will be like (a iKo SaioT eeee). Not (a iKo SaioT eeee). Why the last eeee letter does not change bold? And when $text = "a" The result does not turn into bold too. I need without space too. Because if I put space in array a|i|u|e|o|[:space:]. It will be like this <b>e</b><b>e</b><b>e</b><b>e</b> will be separate. And if i using #([$fonts]?(?=[^$fonts![:space:]]))#us without .+, first and last, fonts not being bold Second, how to convert this code into jquery $newText = preg_replace("#([$fonts].+?(?=[^$fonts![:space:]]))#us", '<b>$1</b>', $text); Cause $fonts is arrays not same in php Link to comment Share on other sites More sharing options...
Jacques1 Posted July 22, 2017 Share Posted July 22, 2017 You should explain what you want to achieve, not how you think it should be done. The entire approach is just weird, and you cannot expect us to deduce the search pattern from a bunch of incorrect regexes. Let's start with a high-level description: Where on your site are you using those patterns, and what is their purpose? Link to comment Share on other sites More sharing options...
ARITABACAN Posted July 22, 2017 Author Share Posted July 22, 2017 You should explain what you want to achieve, not how you think it should be done. The entire approach is just weird, and you cannot expect us to deduce the search pattern from a bunch of incorrect regexes. Let's start with a high-level description: Where on your site are you using those patterns, and what is their purpose? If i using preg_replace('/['.$fonts.']/i', '<b>$1</b>', $text); The result will be like this, right? a iKo SaioT eeee but if you click right and inspect. You can see <b>a</b> <b>i</b>K<b>o</b> S<b>a</b><b>i</b><b>o</b>T <b>e</b><b>e</b><b>e</b><b>e</b> Being separated by spaces But different from using ^$fonts![:space:] To be <b>a</b> <b>i</b>K<b>o</b> S<b>aio</b>T eeee Why i using exeption space? Cause Arabic script is continuous If using ^$fonts![:space:] to be like <b>مَنْ جَاءَ بِا</b> If not <b>م</b><b>َ</b><b>ن</b><b>ْ</b> <b>ج</b><b>َ</b><b>ا</b><b>ء</b><b>َ</b> <b>ب</b><b>ِ</b><b>ا</b> Not same مَ نْ جَ اءَ بِ ا = مَنْ جَاءَ بِا But this problem, like my question in post Why the last eeee letter does not change bold? And when $text = "a" The result does not turn into bold too. Link to comment Share on other sites More sharing options...
Jacques1 Posted July 22, 2017 Share Posted July 22, 2017 Can you read? I'm not interested in your weird regex gymnastics for now. They don't clarify anything, no matter how many times you repeat them. What I want is an explanation of the overall goal. The big picture, not the technical details. Maybe you can understand this better: Let's say I'm a user of your website. An ordinary guy without any programming experience. Now, what does the feature you're trying to implement do for me? Why should I care about it? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.