🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: pl.comp.lang.javascript
2 messages
2 total messages Started by smerf Mon, 19 Apr 2010 16:30
funkcja z wyrazeniem regularnym
#49968
Author: smerf
Date: Mon, 19 Apr 2010 16:30
9 lines
1026 bytes
Znam srednio dobrze wyrazenia regularne i zielony nie jestem.
Ale nie moge poradzic sobie z wyjasniem ciala tej funkcji

function(value, term) {
	return value.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi, "\\$1") + ")(?![^<>]*>)(?![^&;]+;)", 
"gi"), "<strong>$1</strong>");
} 	

Kto mi pomoze i objasni ?
Re: funkcja z wyrazeniem regularnym
#49969
Author: NKAB -
Date: Tue, 20 Apr 2010 07:21
51 lines
1939 bytes
smerf <smerf@akcesoria.home.pl> napisał(a): 

> Znam srednio dobrze wyrazenia regularne i zielony nie jestem.
> Ale nie moge poradzic sobie z wyjasniem ciala tej funkcji
> 
> function(value, term) {
> 	return value.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + 
term.replace(/([\^
> \$\(\)\[\]\{\}\*\.\+\?\|\\])/gi, "\\$1") + ")(?![^<>]*>)(?![^&;]+;)", 
> "gi"), "<strong>$1</strong>");
> } 	
> 
> Kto mi pomoze i objasni ?

Objaśnić może nie objaśnię ale ja to robię tak:

function(value, term) 
{

 return value.replace(

                      new 

                      RegExp(

                             "(?![^&;]+;)
 
                              (?!<[^<>]*)

                              (" +  term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?
\|\\])/gi, "\\$1")  + ")

                              (?![^<>]*>)

                              (?![^&;]+;)

                             ", "gi" 
                            ),

                      "<strong>$1</strong>"

                     );
}

testuj kawałkami (jak się da).

Andrzej.


-- 
Wysłano z serwisu Usenet w portalu Gazeta.pl -> http://www.gazeta.pl/usenet/
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads