In my ASP.NET application I have a plain text field. I want to allow the user to be able to enter URL's in the following format:맞춤 태그를 <a href> tags
[url="http://www.google.com"]Google[/url]
These would be saved to a database directly as they were entered. On retrieveal however, I'd like to convert the above into the following HTML format to make it active on-screen:
<a href="http://www.google.com">Google</a>
The reason for this approach is to avoid tampering with the built-in ASP.NET validation routines, which trigger an error when it sees <a
in a form input string.
I've seen other examples on StackOverflow where RegEx is used to parse the string, however, I cannot find anything that I can follow where multiple occurrences of [url...]
may exist in a single string.
Can anyone please offer me an example of how to parse such a string, say...
Try this funky new search engine: [url="http://www.google.com"]Google[/url] Or this older one from back in the day: [url="http://uk.altavista.com"]AltaVista[/url]
...to convert each occurrence into the desired format? RegEx isn't my strong-point sadly.
Thanks.
거의 비슷한 질문을 (http://chat.stackoverflow.com/transcript/message/9370083#9370083)하지만 PHP에서. ASP에 비슷한 기능이 있다면'size'를'url'과 출력으로 바꿀 수 있습니다 ... 또한 나는 오타'Google' I think you meant 'Google'이 있다고 생각합니다. – HamZa
안녕하세요. 감사합니다. 오타가있었습니다. RegEx의 경우 VB.NET에서는 일치 항목을 반환하지 않습니다. 확실하지 않으면 이중 따옴표가 VB.NET에서 문자열 기호로 간섭하는지 확실하지 않으므로 이중 따옴표를 사용하여 문자열에 단일 큰 따옴표를 반환하십시오. 'Dim \ r 새 정규식으로 "/ \ [url \ s? = \ s?" "? (. *?)"? \] (. *?) \ [\ url \]/s ")' – EvilDr
VB.net 또는 ASP에 익숙하지 않아서 [온라인 테스터] (http://i.stack.imgur.com/L2eL5.jpg)의 스크린 샷을 볼 수 있습니다. [정규식 룸]에 참여할 수도 있습니다 (http://chat.stackoverflow.com/rooms/25767/regex). – HamZa