3
I recently changed the friendly url, because the querystryng used for searches was filtered to without accents. Regarding the queries to the database regardless of whether the word has accent or is not being found. But I used to give a replace to highlight the searched words
Replace (texto, palavra,"<b>" & palavra & "</b>"
In short, how can I use a ereg_replace()
to ignore accents. Example:
Texto="Este é um filme de Ação e tem muita ação. "
Palavra="acao"
texto=Ereg_replace(condição_RegEx_que_ignora_Acentos-e-case, texto, palavra,"<b>"& palavra & "</b>")
'Resultado q preciso:
"Este é um filme de <b>Ação</b> e tem muita <b>ação</b>."
Thanks for your attention
@EDIT to explain better:
i have a word that is without accent coming from querystring, a search: example: What
I need to make a substitution to highlight this word in the text, whether or not it is accented.
Then a text with Small or Tokyo or Tokyo or Tuchium
that was found by the search term: Small or Tokyo or Tokyo or Tuchium
needs to be replaced by the tag itself added <b>...</b>
so any text with the word: Small or Tokyo or Tokyo or Tuchium should get itself added to the tag, like this:
era assim: Fui pra Toquio.
precisa ficar assim: Fui pra <b>Toquio</b>.
mas se for assim: Fui pra Tóquio.
precisa ficar assim: Fui pra <b>Tóquio</b>.
ou ainda: Fui pra tóquio.
precisa ficar assim: Fui pra <b>tóquio</b>.
ou ainda: Fui pra toquio.
precisa ficar assim: Fui pra <b>toquio</b>.
whether the user typed in the search Small or Tokyo or Tokyo or Tuchium
got better @david
I think you’re a little confused, as I understand it, you need an algorithm that when finding the word in the text adds the right <b> </b> tags?
– David
that. independent of case (capital or minuscule) and accents.. Just like the example I put on it
– SuperMax
It just got confused, what you asked "ignore accents", and in case that wouldn’t be it, would have to rephrase your question?
– David
I don’t know Asp, but probably
ereg_replace
accepts capture groups, so if you pass the regex"(" & padrao & ")"
as a first argument, the substitution may be"<b>$1</b>"
and it will insert the word found in the result (and not the default). It remains to know how to make this pattern to ignore accents and capitalization.– mgibsonbr
@david but that’s exactly what I want: to exchange a word; whether it accent or not; for the same words, whether it had accent or not, adding a tag, just that. I believe the term q I used is right and the clear example
– SuperMax
@mgibsonbr, it’s about that, I found a function for Regex in Asp but I’m not sure how to make a condition to meet this, I found a similar need in American stackoverflow but it’s in php and I didn’t get it right, pq no longer know mto of php in English yet... http://stackoverflow.com/questions/10477213/regex-to-ignore-Accents-php
– SuperMax
I don’t know Sp... :( Take a look in that other question (for Javascript) - in particular that answer - and see if it gives you light. The idea is to replace each letter in the pattern with a set of "similar" characters, before using on
ereg_replace
. So if your word isacao
, its final regex would be[aAáÁâÂàÀãÃ][cCçÇ][aAáÁâÂàÀãÃ][oOóÓôÔòÒõÕ]
. You would need to create a function to from the search term create this regex.– mgibsonbr
P.S. Just clarifies one thing: you’re using classic ASP even, not ASP.Net, right?
– mgibsonbr
@mgibsonbr, sim Asp classico
– SuperMax
@mgibsonbr, I had found this page, but I couldn’t convert it to a similar Asp function. On this page https://github.com/chiquitto/FuncoesASP/blob/master/lb.string.asp has the function ereg_replace, which I believe does what I need, but I don’t know exactly how it would be used, especially the Pattern for it to work doing what I need
– SuperMax
@David I edited to explain in more detail, see if it’s clear to you.
– SuperMax