Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Excluding pattern from regex
#1
1. this is text with //a comment

2. this is text with a link http://example.com


Looking for the to correct regular expression to remove from "//" to the end of the line in #1 but not remove "//" to the end of the line in #2

Thanks,
Jim

Edit:
Code:
Copy      Help
s.replacerx("(?<!http:)//.*\r\n")
#2
if just need single replacement use flag 4
Function Function185
Code:
Copy      Help
s.replacerx("//" "" 4)

or
Function Function185
Code:
Copy      Help
str s=
;this is text with //a comment
;blah
;blah
;this is text with a link http://example.com
;this is text with //a comment also
;this is text with a link also http://www.example.com
s.replacerx("(?<!http:)//")
out s
#3
This is to remove comments from javascript. Need multiple replacements. Figured the syntax out for not preceded by (?<!httpSmile
#4
Code:
Copy      Help
s.replacerx("(?<!:)//.*\r\n")


Forum Jump:


Users browsing this thread: 1 Guest(s)