PeeerMedlem sedan mars 20025 907 inlägg objRegExp.Pattern = "\[LIST\](.*?)\[\/LIST\]"
strText = objRegExp.Replace(strText,"<ul>$1</ul>")
objRegExp.Pattern = "\<ul\>(.*?)\[\*\](.*?)\<\/ul\>"
strText = objRegExp.Replace(strText,"<ul>$1<li>$2</ul>")
Hjälp! Som det är nu så blir endast den första omvandlad till en punkt.
PeeerMedlem sedan mars 20025 907 inlägg Använder jag redan! :(
mer tips?
hela koden:
Set objRegExp = New regexp
objRegExp.Global = true
objRegExp.IgnoreCase = true
objRegExp.Pattern = "\[LIST\](.*?)\[\/LIST\]"
strText = objRegExp.Replace(strText,"<ul>$1</ul>")
objRegExp.Pattern = "\<ul\>(.*?)\[\*\](.*?)\<\/ul\>"
strText = objRegExp.Replace(strText,"<ul>$1<li>$2</ul>")
PeeerMedlem sedan mars 20025 907 inlägg Nästan 10 timmar senare, fortfarande ingen som har svarat! :(
Function encode(strText)
Set objRegExp = New regexp
objRegExp.Global = true
objRegExp.IgnoreCase = true
strText = Server.HTMLEncode(strText)
objRegExp.Pattern = "\[list\]((.|\n)+?)\[\/list\]"
strText = objRegExp.Replace(strText,"<ul>$2</ul>")
objRegExp.Pattern = "\[\*\](.*?)"
strText = objRegExp.Replace(strText,"<LI>$1</LI>")
End Function
Fungera fin fint hos mej..
PeeerMedlem sedan mars 20025 907 inlägg Njae. Inte helt fin kan jag väl inte påstå. För det första så har du glömt en rad i koden (encode=strText), sen så blir resultatet inte som jag vill.
Allt som står mellan [.LIST] och [/.LIST] försvinner, det skrivs inte ut.
Om det däremot står ex [.LIST=a] och [/.LIST=a] så blir det riktigt konstigt. Då skrivs [.list=a] ut medans ersätts med punkter. Har försökt visa hur det ser ut nedan.
[.list=a]
tjoh
dfg
dfsd
sdf
[./list=a]
LarsGMedlem sedan dec. 200012 464 inlägg Jo, problemet är ju att med ditt andra mönster så matchar du hela "<ul> a b </ul>" och inte enskilda " a"
Jag tror att du måste välja en annan ansats, kanske något åt detta håll
Set objRegExp = New regexp
objRegExp.Global = true
objRegExp.IgnoreCase = true
objRegExp.Pattern = "\[LIST\].*?\[\/LIST\]"
set matches = objRegExp.execute
offset = 0
for each match in matches
str = "<ul>" & replace(match.value,"[*]","<li>") & "</ul>"
strText = mid(strText,1,match.firstIndex-1+offset) & str & mid(strText,match.FirstIndex+match.length)
offset = offset + match.length - len(str)
next
Helt otestat förstås.
Mer info om matches:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vtoriObjects.asp
PeeerMedlem sedan mars 20025 907 inlägg Function reg(strText)
Set objRegExp = New regexp
objRegExp.Global = true
objRegExp.IgnoreCase = true
objRegExp.Pattern = "\[list\].*?\[\/list\]"
set matches = objRegExp.execute[b](strText)[/b]
offset = 0
for each match in matches
str = "<ul>" & replace(match.value,"[*]","<li>") & "</ul>"
strText = mid(strText,1,match.firstIndex-1+offset) & str & mid(strText,match.FirstIndex+match.length)
offset = offset + match.length - len(str)
next
reg=strText
End function
Har markerat det enda felet jag hittade (efter läsningen), men något är fel för nu skrivs hela strängen ut. Utan att något ändras.
Mer hjälp tack! :)
PeeerMedlem sedan mars 20025 907 inlägg Det här går inte bra! Får det inte att funka.
Någon?? :(
emissionMedlem sedan dec. 19996 721 inlägg objRegExp.Pattern = "\[LIST\](.*?)\[\/LIST\]"
for each match in objRegExp.execute(strText)
strText=replace(strText,match.value,"<ul>" & replace(match.submatches(0),"[*]","<li>") & "</ul>")
next
PeeerMedlem sedan mars 20025 907 inlägg Suck. Får det inte att funka :(
Function reg(strText)
Set objRegExp = New regexp
objRegExp.Global = true
objRegExp.IgnoreCase = true
objRegExp.Pattern = "\[LIST\](.*?)\[\/LIST\]"
for each match in objRegExp.execute(strText)
strText=replace(strText,match.value,"<ul>" & replace(match.submatches(0),"[*]","<li>") & "</ul>")
next
reg=strText
End function
anropas genom <%=reg(text(1))%> ( text(1) är en del av en array)