Thread: Regex examples
View Single Post
Old 09-20-2014, 08:53 PM   #416
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,465
Karma: 192992430
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by JimmyG View Post
Okay this regex $(.+)^ finds whole lines with text in them.

But I don't want lines that start with <, so I tried this $([^<].+)^
but that includes any preceding blank line and the next line, whether it starts with < or not, and I don't know why.

I want whole lines (not empty) that don't start with a tag.
You got your anchors flipped ^ is the beginning of a string(or line) and $ is the end.

But even ^([^<].+)$ isn't going to be very useful in a Sigil formatted file. "Lines" get very hairy in a file. A paragraph is typically on one "line" (meaning no line-break characters) from <p> to </p>. Same with just about any block-level element. And many lines are likely to be indented, so they don't start with "<" they start with a space. That's probably why they're getting included in your search.

It's including blank lines because blank lines DON'T start with a "<", they start with line-break character(s).

There really shouldn't be any (or very, very few anyway) "lines" that don't begin with a "<" (or an indent before a "<"). Some css styling in the header and the like maybe.

If it's these relatively rare instances you're looking for perhaps something like:
Code:
^\w.+$
might come close?
DiapDealer is online now   Reply With Quote