Visa ett inlägg
Oläst 2008-01-02, 22:17 #5
Ungdebatt Ungdebatt är inte uppkopplad
Nykomling
 
Reg.datum: Apr 2007
Inlägg: 30
Ungdebatt Ungdebatt är inte uppkopplad
Nykomling
 
Reg.datum: Apr 2007
Inlägg: 30
Jag har testat med följande kod, men mina RegExp kunskaper är tydligen inte tillräckliga. Jag har testat med att bryta ut \r \n och \s

Kod:
strText = "texten här som ska bearbetas"

With New RegExp
IgnoreCase = TRUE
.Global = TRUE
.Pattern = "(\n|\r|)"
Set objMatches = .Execute(strText)

strResult = ""
lngPos = 1

For Each objMatch In objMatches
 If objMatch.FirstIndex > lngPos Then
  strResult = strResult & Mid(strText, lngPos, objMatch.FirstIndex - lngPos + 1)
  inti = inti + 1
 End If

 strFound = inti & objMatch & "<br />" 
 strResult = strResult & strFound
 lngPos = objMatch.FirstIndex + objMatch.Length + 1
Next
   	
strNewText = strResult & Mid(strResult, lngPos)

End With
EDIT:
@martine
#1. Den ska reagera på radbrytning, vbcrlf, då skapar den en ny rad
#2. Den ska reagera på ifall en rad är längre än t.ex. 800 tecken, då gör den en ny rad.
Ungdebatt är inte uppkopplad   Svara med citatSvara med citat