bookmarks line with value numbers
-
hi great community,
i’ve some document like this:
text chw 12.34 aa text gsh text als 18.57 aa text owp text wal 35.81 aa text gph
i need to bookmaks all lines with value below
14.00 aa
so, from the example above, the second line with12.34 aa
value
how to ? -
In general, searches cannot do math (add, subtract, compare matched value to a real value like
14.00
), even the “regular expression” syntax.However, with some data, it’s possible to overcome this limitation by a more-complicated regular expression.
For your data as presented, with some simple assumptions I will enumerate, it’s possible and not too onerous.
Assumptions
- All numbers that will match:
- start at the beginning of the line (no leading spaces)
- will be unsigned (no - or + before them)
- have at least one digit before the decimal point
- have exactly two digits after the digits
- You want to match and bookmark any that are from
0.00
-13.99
, followed by a space and two lowercase lettera
characters.14.00 aa
will not be matched or bookmarked, because it is not below 14.00.1.23 ab
will not match because it’s gotab
notaa
.
Procedure
- Search > Mark
- FIND WHAT =
^(\d|1[0123])\.\d{2} aa
- mark the checkbox
☑ Bookmark Line
- mark the checkbox
☑ Purge for each search
(assuming you _want _ to reset the marks every time) - Search Mode = Regular Expression
- MARK ALL
FIND explanation
^
= start match at start of line(...)
= a “group”, which I’m using as a wrapper|
= the|
is the symbol for “OR”; I put it in a group so that(A|B)
will match A or B\d
= a single digit (0-9)1[0123]
= matches a1
followed by0
or1
or2
or3
- thus,
(\d|1[0123])
= matches either 0-9 or 10-13 \.
= matches a literal.
decimal point\d{2}
= matches two digits (so00
-99
)- everything remaining matches literally
----
Thank you for putting your text in a text block.
Useful References
- All numbers that will match:
-
I just noticed that this is your third regex topic. Please read and understand the concepts below.
—
Please note: This Community Forum is not a data transformation service; you should not expect to be able to always say “I have data like X and want it to look like Y” and have us do all the work for you. If you are new to the Forum, and new to regular expressions, we will often give help on the first one or two data-transformation questions, especially if they are well-asked and you show a willingness to learn; and we will point you to the documentation where you can learn how to do the data transformations for yourself in the future. But if you repeatedly ask us to do your work for you, you will find that the patience of usually-helpful Community members wears thin. The best way to learn regular expressions is by experimenting with them yourself, and getting a feel for how they work; having us spoon-feed you the answers without you putting in the effort doesn’t help you in the long term and is uninteresting and annoying for us.
-
wow, great solution. wonderful
it work fine, thank you Peterabout your second post: i agree, and i’ve try to search around the web some solution, but i didn’t find anything useful, and few have the knowledge as you have
I hope in the future to increase my notions, in fact i’m following all the threads here!all the best