I just want to add a dash!
October 13, 2009 1:33 PM   Subscribe

I'm using the find and replace tool in dreamweaver, ultilizing Regular Expressions to find four numbers and a space and then 'replace' that expression with itself but add a dash.

I have a series of years and descriptions, it looks something like this:

1991 Event Number 1
1992 Event Number 2
1994 Event Number 3
1997 Event Number 4

I want to turn that into:

1991
- Event Number 1

1992
- Event Number 2

1994
- Event Number 3

1997
- Event Number 4

I don't want to do it manually, because there's something like 200 some-odd dates. I've managed to deceiver a regular expression to find the year and space ([0-9][0-9][0-9][0-9] ) but I can't seem to get dreamweaver to replace the found expression with itself.

Is that possible? if not, is there any method I can use to find the 5th character in a line, or the first space in a line?

Any suggestions?

(fyi: the end document will be a html page.)
posted by royalsong to Computers & Internet (7 answers total) 2 users marked this as a favorite
 
Generally, the way to reference the Nth parenthesized expression in a match to use it in the replacement text is \N (where N is some integer). So try \1 in the replacement text. Perl-like languages or apps sometimes use $1 instead.

Also, you can simplify ([0-9][0-9][0-9][0-9]) into (\d{4}) if Dreamweaver supports Perl-compatible regular expressions.
posted by letourneau at 1:41 PM on October 13, 2009


Best answer: Google says you can, using $1.
posted by themel at 1:50 PM on October 13, 2009


Best answer: So just for some basics - this may not be exact but should be close

find:
(\d{4}\s)(Event Number \d)

replace:
$1\n- $2
posted by bitdamaged at 1:53 PM on October 13, 2009


do the lines look like this in the html?

1991 Event Number 1<>

if so, simply use the Find and Replace command.

first replace the <> with <><>

then replace the Event with <>-Event

Note: I replaced br with *br* because it wouldn't show up otherwise
posted by digsrus at 5:34 PM on October 13, 2009


The above comment didn't show up as expected.

the <> should have a br between them.
posted by digsrus at 5:36 PM on October 13, 2009


bitdamaged should have it for the most part, but you'll want this:
find:
(\d{4})\s(Event Number \d)

otherwise the trailing space after the year will remain, which I don't think you need.

I've used a similar construct in a grep-compliant editor to fix files; the $1 matches anything inside the first parentheses, $2 is the second set, etc.
posted by caution live frogs at 6:05 AM on October 14, 2009


Response by poster: Thanks everyone, $1 worked perfectly!

and just an fyi, the events were placeholders. They were more like: Sally moved to Russia, Mike wrote his autobiography, Tasha got married, etc.
posted by royalsong at 6:11 AM on October 15, 2009


« Older ship or rent?   |   I need a new computer Newer »
This thread is closed to new comments.