They may differ based on the symbols reserved by the various languages. Basically, it is an expression that defines a pattern, from which one or more parts can be defined as variable and also be restricted as to which content they may include. The function principle is the same anywhere. I found a tutorial for reg exp here:
http://www.mkssoftware.com/docs/man5/regexp.5.asp
Problems Applying Stylesheet Instead of Local Formatting
-
- Senior Propellus Maximus
- Posts: 4293
- Joined: Thu Feb 02, 2006 9:29 am
- Location: The Electric City
Re: Problems Applying Stylesheet Instead of Local Formatting
New Book: Creating user-friendly Online Help
Paperback http://www.amazon.com/dp/1449952038/ or https://www.createspace.com/3416509
eBook http://www.amazon.com/dp/B005XB9E3U
Paperback http://www.amazon.com/dp/1449952038/ or https://www.createspace.com/3416509
eBook http://www.amazon.com/dp/B005XB9E3U
Re: Problems Applying Stylesheet Instead of Local Formatting
Hi Kevin!
In fact i'm aware of the setting you are talking about. it works fine in V4.1 (I'm already using it), but in V3.1 it seemed to be searching the whole project but didn't show the results. It showed neither Find Results 1 nor Find Results 2. That's why I said that it was poor.
But thanks for the reply
In fact i'm aware of the setting you are talking about. it works fine in V4.1 (I'm already using it), but in V3.1 it seemed to be searching the whole project but didn't show the results. It showed neither Find Results 1 nor Find Results 2. That's why I said that it was poor.
But thanks for the reply
Alice
Re: Problems Applying Stylesheet Instead of Local Formatting
When I had a look I had a look a while back, I bookmarked these two...Alice wrote:So does anybody know some quick and easy way to get the idea and the basics of those FRIGHTENING regular expressions?
http://www.regular-expressions.info/
http://zytrax.com/tech/web/regex.htm
It looks pretty powerful, but I couldn't quite get my head round it.
I think there's a mix-up here, Flare has two 'finds' - a find and replace and a find in files. The find and replace pane is where you'd do a find and replace using regular expressions, and it has a setting to find in the whole project (which worked fine in v3.1).Alice wrote:In fact i'm aware of the setting you are talking about. it works fine in V4.1 (I'm already using it), but in V3.1 it seemed to be searching the whole project but didn't show the results. It showed neither Find Results 1 nor Find Results 2.
The find in files pane is just for finding something in your files (with no replace), and it puts the list of matches in the Find Results 1 or 2 panes. The Find Results 1 and 2 panes are only used with the find in files, not find and replace.
Re: Problems Applying Stylesheet Instead of Local Formatting
in v3.1 in find in files flare didn't display neither of the results panes, since i couldn't find and look through cirtain things, i didn't dare to run find and replace. so i was just careless with wording.Dave Lee wrote:I think there's a mix-up here, Flare has two 'finds' - a find and replace and a find in files.
In fact i didn't spend much time solving the problem(i tried-> it didn't work out->i dropped it). It's only now that i started active editting, projects restructing and cleaning up (due to the fact that after lot's of work i'll aply GPL and will save myself lots of effort). And all the stuff started because i want to single source the stylesheet.
thanks a lot. I've already been to http://www.regular-expressions.info and it seems nice, I'll look through the other one. In addition i discovered some links in my native language. Although i'm a certified specialist in English such important things shoud be studied in both languages
Thanks again
Alice
Re: Problems Applying Stylesheet Instead of Local Formatting
Good luck. I think most of the stuff I found about regular expressions was written in geek rather than English!
Re: Problems Applying Stylesheet Instead of Local Formatting
hurray!
I made my first regular expression and it was sucsessful!
I made my first regular expression and it was sucsessful!
Alice
Re: Problems Applying Stylesheet Instead of Local Formatting
Hi, glad the regular expression was helpful. Useful to know that you can use these in Flare. They are definitely tricky but quite powerful and probably reward the effort needed to learn them although maybe it is easier to use a tool like FAR. Anyway, here is an attempt at an explanation as to how the following regular expression works:
Search Expression:
img src="([^"]+)[^>]+
Replace Expression:
img src="\1" class="Centre" /
[^"]+ matches as many characters as possible until it hits this character " - this captures the image filename and path.
Putting it in brackets ([^"]+) means, remember what we matched here - this is called a backreference.
[^>]+ matches as many characters as possible until you hit this character >
Example: <img src="C:/test/image.jpg" style="abcde"/>
[ab] is called a character set in the jargon of regular expressions; it matches 1 character either a or b
[^a] matches 1 character as long as it is not a
to match more than one character you need to put a + after the character set. This is a "greedy" match it tries to match as any many characters as possible. I think there is a "lazy" match but I have never used it.
[^"]+ matches C:/test/image.jpg
[^>]+ matches style="abcde"/
In total we match img src="C:/test/image.jpg" style="abcde"/
\1 is the contents of the 1st backreference in the search expression, so whatever matched that part of the search expression. If we used a second backreference you would use \2, etc.
As mentioned before in total in the example we match img src="C:/test/image.jpg" style="abcde"/
"\1" class="Centre" / in the replace expression is "C:/test/image.jpg" class="Centre" / in this example
So we replace img src="C:/test/image.jpg" style="abcde"/ with "C:/test/image.jpg" class="Centre" / ....Phew!
My advice on regular expressions is:
1. Cheat and copy ones other people have made already!
2. If you can't do 1 then build a regular expression up in pieces and test each piece works before making the expression more complicated. Make sure you get the search part perfect and that you are not matching anything you don't expect.
3. Learn what the special characters are (metacharacters in the jargon) these are +()*?\ etc. if you want to match these in text then you must put a \ in front of them like so \( to match ( This is called "escaping". This is really annoying! Especially if you want to match \ then you need to put \\. This is very easy to get wrong! Sometimes . is a metacharacter as well that matches any character (as people have mentioned they do vary a bit in different applications).
4. Learn character sets [] \d \s \w + and . backreferences and ().
5. Use lazy evaluators rather than greedy ones: +? and *? rather than + and *
6. Use negative character sets where you can e.g. <img[^>]+> to match an img tag
That should get you started.
I second the recommendation for this site: http://www.regular-expressions.info/tutorial.html
Cheers, Ian
Search Expression:
img src="([^"]+)[^>]+
Replace Expression:
img src="\1" class="Centre" /
[^"]+ matches as many characters as possible until it hits this character " - this captures the image filename and path.
Putting it in brackets ([^"]+) means, remember what we matched here - this is called a backreference.
[^>]+ matches as many characters as possible until you hit this character >
Example: <img src="C:/test/image.jpg" style="abcde"/>
[ab] is called a character set in the jargon of regular expressions; it matches 1 character either a or b
[^a] matches 1 character as long as it is not a
to match more than one character you need to put a + after the character set. This is a "greedy" match it tries to match as any many characters as possible. I think there is a "lazy" match but I have never used it.
[^"]+ matches C:/test/image.jpg
[^>]+ matches style="abcde"/
In total we match img src="C:/test/image.jpg" style="abcde"/
\1 is the contents of the 1st backreference in the search expression, so whatever matched that part of the search expression. If we used a second backreference you would use \2, etc.
As mentioned before in total in the example we match img src="C:/test/image.jpg" style="abcde"/
"\1" class="Centre" / in the replace expression is "C:/test/image.jpg" class="Centre" / in this example
So we replace img src="C:/test/image.jpg" style="abcde"/ with "C:/test/image.jpg" class="Centre" / ....Phew!
My advice on regular expressions is:
1. Cheat and copy ones other people have made already!
2. If you can't do 1 then build a regular expression up in pieces and test each piece works before making the expression more complicated. Make sure you get the search part perfect and that you are not matching anything you don't expect.
3. Learn what the special characters are (metacharacters in the jargon) these are +()*?\ etc. if you want to match these in text then you must put a \ in front of them like so \( to match ( This is called "escaping". This is really annoying! Especially if you want to match \ then you need to put \\. This is very easy to get wrong! Sometimes . is a metacharacter as well that matches any character (as people have mentioned they do vary a bit in different applications).
4. Learn character sets [] \d \s \w + and . backreferences and ().
5. Use lazy evaluators rather than greedy ones: +? and *? rather than + and *
6. Use negative character sets where you can e.g. <img[^>]+> to match an img tag
That should get you started.
I second the recommendation for this site: http://www.regular-expressions.info/tutorial.html
Cheers, Ian
Last edited by iand on Tue Mar 31, 2009 4:51 am, edited 1 time in total.
Re: Problems Applying Stylesheet Instead of Local Formatting
Unfortunately my free trial of Powergrep has expired and I have had to fall back on Flare's regular expression feature. I hit a problem here, Flare doesn't support the use of backreferences which rules out many applications of regular expressions such as putting every <img ..../> tag inside a div tag in all your files.
Backreferences allow you to use what you match with your regular expression in replacement text.
I encourage everyone who uses regular expressions in Flare to submit a bug request for this at the usual place: http://www.madcapsoftware.com/bugs/submit.aspx
Backreferences allow you to use what you match with your regular expression in replacement text.
I encourage everyone who uses regular expressions in Flare to submit a bug request for this at the usual place: http://www.madcapsoftware.com/bugs/submit.aspx