워드에서 정규식 쓰기

|

 

원문: http://office.microsoft.com/en-us/help/HA010873041033.aspx


The examples on this reference page show you some of the ways that you can use wildcard characters and regular expressions in Microsoft Word. For an introduction to this subject, see Add power to Word searches with regular expressions.

Example 1: Transpose names with middle initials

The article Add power to Word searches with regular expressions explained how to use wildcard characters and a regular expression to transpose names—for example, to change "Colin Wilcox" to "Wilcox, Colin." But what do you do if some or all of the names contain middle initials or middle names? This example uses a combination of wildcard characters and character codes to transpose names that contain middle initials. If you're unfamiliar with character codes, see the Word Help topic titled "Find and replace text or other items."

Keep these facts in mind as you proceed:

  • Whenever you use this expression on names that reside in a table, you must first convert that table to text.
  • If the table contains more than one column, copy the column containing the names to a blank document and convert it to text there.
  • After you transpose the names, convert the text back to a table. You can then delete the original column and replace it with your changed data.

Follow the steps in these examples to walk through the entire process.

To prepare sample data
  1. If you haven't already done so, start Word and create a new, blank document.
  2. Insert a blank table into the document. Make the table one column wide by four rows high.
  3. Copy these names individually, and paste each one into a blank table cell: Joshua Quentin Barnhill
    Doris X. Hartwig
    Tamara Y. Johnston
    Daniel Shimshoni
    Your table should look something like this:

    Joshua Quentin Barnhill
    Doris X. Hartwig
    Tamara Y. Johnston
    Daniel Shimshoni

  4. Select the table, and on the Table menu, point to Convert, and then click Table to Text.
  5. Select Paragraph marks as the text separator, and then click OK.
To transpose names with initials
  1. On the Edit menu, click Find to open the Find and Replace dialog box.
  2. Select the Use wildcards check box (you may need to click More to see the check box), and then enter the following expression in the Find what box: (*) ([! ]@)^13
  3. Enter the following expression in the Replace with box: \2, \1^p Make sure you enter a space between the two sets of parentheses and after the exclamation point. If you haven't seen the ^13 character before, we explain what it does in the next section.
  4. Select the list of names, and then click Replace All. Word transposes the names and either middle initials or middle names, like so:

Barnhill, Joshua Quentin
Hartwig, Doris X.
Johnston, Tamara Y.
Shimshoni, Daniel

To convert the changed text back to a table
  1. Select the list of transposed names.
  2. On the Table menu, point to Convert, and then click Text to Table. The Convert Text to Table dialog box opens.
  3. Under Separate text at, click Paragraphs, and then click OK.

The expressions dissected

Let's look at the individual pieces of the expression to see how they work, starting with the second half of the expression in the Find what box.

The entire expression looks for two groups of patterns: a first name with a middle initial (or a middle name) and a last name. This part of the expression matches the last names:

([! ]@)^13

We need to know where the last name ends, so we also use the ^13 character to search for the paragraph mark at the end of each line. However, since we don't plan to reuse the paragraph mark, we surround everything else with parentheses.

You can try this by copying the names to your test document again (make sure you separate them with paragraph marks), and then search using ([! ]@)^13 in the Find what box. Search matches each last name.

Because search starts again at the beginning of the next line, we use the asterisk wildcard character (*) to match everything from there to the beginning of the next last name.

Since we don't plan to reuse the space in front of the last name, we use parentheses to exclude it from the two groups:

(*) ([! ]@)^13

 Important   Be careful when using the ^13 character code. Normally, you can use the ^p character code to search for paragraph marks. However, that code does not work in wildcard searches. Instead, you need to use the substitute code ^13. Although the ^p character code does not work in wildcard searches, you should use it in wildcard replace operations. Why? The ^p character includes formatting information, and the ^13 character does not. In addition, you cannot assign style information to the ^13 character at all. Misusing the ^13 code in a replace operation can essentially convert your document into a file that you cannot format.

In the Replace with box, the \2, characters tell search to write the second pattern first and to add a comma after the pattern. The \1^p characters tell search where to write the first pattern and to write a paragraph mark after that pattern.

Example 2: Transposing dates

You can use the regular expressions shown here to convert dates in European format to dates in the U.S. format.

To transpose dates
  1. Copy and paste the following date into your document: 28th May 2003
  2. Open the Find and Replace dialog box, and enter the following expression in the Find what box: ([0-9]{1,2})([dhnrst]{2}) (<[ADFJMNOS]*>) ([0-9]{4}) Make sure you insert a space between the following opening and closing parentheses: 2}) (<[ and *>) ([0.
  3. Enter the following expression in the Replace with box (make sure you insert a space between each set of characters), and then click Replace All: \3 \1, \4

    Search replaces 28th May, 2003 with May 28, 2003.

The expression, piece by piece

Let's start with the expression in the Find what box. The expression works by breaking dates down into four patterns, denoted by the sets of parentheses. Each pattern contains the components that you find in all dates written in the style that you used in the example. Working from left to right:

  • The number range [0-9] matches the single-digit numbers in the first pattern. Because dates can consist of two numbers, we tell search to return either one-digit or two-digit dates: {1,2}. The result is the first pattern: ([0-9]{1,2}).

    Ordinals make up the second pattern. Ordinals consist of "th," "nd," "st," and "rd," so we add those letters to a range [dhnrst]. Because ordinals always consist of two letters, we restrict the letter count to two: ([dhnrst]{2}).

  • Next comes a space, followed by literal and wildcard characters that find month names. All month names begin with these capital letters: ADFJMNOS. We don't know how many characters follow each capital letter, so we follow them with the asterisk (*). We're only interested in the month name itself, so we use greater-than and less-than characters to limit the results to the individual word. The result is the fourth pattern: (<[ADFJMNOS]*>).
  • Finally, we search for the year. We use the same number range, but this time we restrict the count to four letters ([0-9]{4}).

In the Replace with box, notice that we only wrote three of the four address patterns. We omitted the ordinal (the "th") from the date because dates in the U.S. format don't use ordinals. If you want to leave the ordinal in the date, enter \3 \1\2, \4 in the Replace with box. In this case, you enter a space both after the 3 and after the comma, nowhere else.

At this point, you may ask how to handle dates in which the name of the month isn't spelled out, such as 28/05/03. You search using this expression:

([0-9]{1,2})/([0-9]{1,2})/([0-9]{2})

You replace using this expression:

\3/\1/\2

If the date takes the format of 28/05/2003, you use {4} in the last pattern instead of {2}.

About using list separators in regular expressions

The previous example uses the following argument to find either one-digit or two-digit dates: {1,2}. In this case, a comma separates the two values. However, remember that your regional settings in Microsoft Windows® control the list separator that you use. If your regional settings specify the use of semicolons as list separators, you must use them instead of commas.

To find out which list separator your operating system specifies
  1. Click Start, point to Settings, and then click Control Panel.
  2. Double-click Regional Settings (if you use Windows Me, Windows 98, or Windows NT®), Regional Options (if you use Windows 2000), or Regional and Language Options (if you use Windows XP).

     Note   If you use Category view in Windows XP, you only need to click Regional and Language Options once.

The following table describes how to find the list separator setting for the supported versions of Windows.

Operating System Steps to find your list separator
Windows XP
  1. After you click or double-click the Regional and Language Options command, the Regional and Language Options dialog box opens. On the Regional tab, click Customize. The Customize Regional Options dialog box opens.
  2. Click the Numbers tab, and then locate the List separator entry.
Windows 2000
  1. After you double-click the Regional Options command, the Regional Options dialog box opens.
  2. Click the Numbers tab, and then locate the List separator entry.
Windows Me, 98, and NT
  1. After you double-click the Regional Settings command, the Regional Settings dialog box opens.
  2. Click the Numbers tab and locate the List separator entry.

Example 3: Add periods to, or remove them from, salutations

In some countries, honorific titles (Mr., Mrs., and so on) do not include periods. This example shows you how to add periods to or remove them from honorifics. From this point on, we assume that you know how to use the Find and Replace dialog box.

This expression finds Mr, Ms, Mrs, and Dr without periods:

<([DM][rs]{1,2})( )

Notice that the expression uses a second pattern containing a blank space. That space normally would follow the honorific if the period was not there. This expression adds the period:

\1.\2

To do the reverse, search using this expression:

<([DM][rs]{1,2}).

And replace using this expression:

\1

Example 4: Find duplicate paragraphs or rows

When you use this expression, you may want to sort the list first to place duplicate rows next to each other. Also, you need to remove all blank paragraph marks. In other words, if you use blank paragraphs to separate blocks of text, like so:

Joshua Quentin Barnhill¶

Joshua Quentin Barnhill¶

Doris X. Hartwig¶

you need to remove those paragraphs, like so:

Joshua Quentin Barnhill¶
Joshua Quentin Barnhill¶
Doris X. Hartwig¶

You can use your favorite method to remove the blank paragraphs, but since we're talking about regular expressions, here's one that finds two consecutive paragraph characters. Search using this expression (the @ character repeats the find-and-replace operation and removes all multiple empty lines):

(^13)\1@

You replace the results with this expression:

^p

Now let's look at ways to replace text. This expression finds any sequence of two consecutive identical paragraphs:

(*^13)\1

This expression also matches longer repetitions of text that end in paragraphs. For example, run the expression against the following list:

Joshua Quentin Barnhill¶
Doris X. Hartwig¶
Joshua Quentin Barnhill¶
Doris X. Hartwig¶
Tamara Y. Johnston¶

Search finds the first four lines and stops only when the overall pattern changes. In contrast, if you run the expression against this list:

Joshua Quentin Barnhill¶
Joshua Quentin Barnhill
Doris X. Hartwig¶
Doris X. Hartwig¶

The expression finds only the first two paragraphs. 

To search for a greater number of identical items, add more placeholders. For example, this expression finds three consecutive identical paragraphs:

(*^13)\1\1

You can also use braces to do the same thing. The following examples find two and three identical paragraphs, respectively:

(*^13){2}
(*^13){3}

Or, you can find either two or three identical paragraphs:

(*^13){2,3}

You can also find two or more identical paragraphs:

(*^13){2,}

You can replace any of those expressions with the following string:

\1

In addition, you can repeat the find-and-replace operation as needed to replace all the duplicate paragraphs in your document, or you can add the @ wildcard character and have the expression repeat the operation for you:

(*^13)\1@

You also use this method to replace duplicate rows in a table. To do so, first remove any merged cells, and then sort the table to place duplicate cells adjacent to each other. Next, convert your table to text. (On the Table menu, point to Convert, and then click Table to text; when prompted, use the tab delimiter.) After you make your replacements, convert the text back to a table.

More examples

And

기본 리눅스/유닉스

|
HP_UX> glance
화면 정렬 " O "

* CPU 확인하는 법

/proc/cpuinfo 의 내용 중에 physical id : 0 이 항목이 있습니다. 이것은 CPU 자체의 ID값입니다. 

예를 들어 어떤 서버의 processor 항목이 최대 1까지 있으면 dual 1개만 있던가, single 2개가 꼽혀 있다는 얘긴데 physical id 가 0만 있다면 single 2개가 꼽혀 있다는 얘기로 보면 됩답니다.

또 듀얼/쿼드 코어 CPU에는 core id 라는 항목이 따로 있습니다. 이거 없으면 single 입니다.

가장 간단한 방법은...
싱글/듀얼/쿼드 구분은 core id가 있느냐 없느냐로 판별하면 되고
듀얼/쿼드의 구분은 core id 아래 필드인 cpu cores라는 필드의 값으로 판별하시면 됩니다.

OS
 uname -a
 /etc/redhat-release

 

CPU
 /proc/cpuinfo
 /sbin/dmidecode 

 

internal disk 정보 확인
   cat /proc/scsi/scsi


s/w 미러인 경우
   cat /proc/mdstat  

 

hp장비에서 internal disk raid 정보보기.
cat /proc/driver/cciss/cciss*


And

다음 로드뷰로 돌아보는 제주도.

|

오늘 로드뷰가 제주도와 5대 광역시를 오픈했다고 해서...

제주도에서 생각나는 것을 몇군데 뒤져봤다..^^


1. 북제주 해안도로

용두암에서 하귀-애월까지 해안 도로는 언제봐도 멋지다..ㅠ ㅠ

비록 차는 없지만, 점심 시간이라던지 주말에 자주 파도보러 가는 곳!!

특히 파도가 높은 날에는 부서지는 파도에 마음까지 시원해진다~

더 멋진 장소도 많은데 대충 찾아서 이정도의 풍경~

http://local.daum.net/map/index.jsp?cx=383351&cy=131765&level=3&panoid=1859873&pan=332.2215351340029&tilt=5.514718778134164&map_type=TYPE_MAP&map_hybrid=false&map_attribute=ROADVIEW&screenMode=normal



2. 우도 - 언덕

제주에서 최고의 관광지를 꼽자면, 단연 우도!!

가서 한번도 후회한 적이 없다~~

한여름에는 사람이 많으니까, 성수기를 피해서 가주는 센스~~

등대 올라가는 언덕길..바람도 많이 불고...이국적인 풍경이 정말 멋지다.

http://local.daum.net/map/index.jsp?cx=491275&cy=123613&level=5&panoid=1454459&pan=234.79513897053374&tilt=15.875705573416575&map_type=TYPE_MAP&map_hybrid=false&map_attribute=ROADVIEW&screenMode=normal


3. 우도 - 산호사 해수욕장

해초들이 굴러서 만들어진 특이한 모래가 인상적인 곳...

하지만 모래 보다는 바다가 너무 좋다!!!

깨끗한 바다!! 정말 가서 보면 깜짝 놀랄만큼 맑은 바다 빛을 볼 수 있다~

우도는 정말 이국적인 해안을 보여준다..

http://local.daum.net/map/index.jsp?cx=486562&cy=126760&level=2&panoid=1454652&pan=298.22471273312965&tilt=0.5848944158627172&map_type=TYPE_MAP&map_hybrid=false&map_attribute=ROADVIEW&screenMode=normal

ㅋㅋㅋ 참 잼있게 놀았더랬지~

http://local.daum.net/map/index.jsp?cx=486664&cy=126669&level=5&panoid=1454742&pan=265.73014816718876&tilt=8.689859892817484&map_type=TYPE_MAP&map_hybrid=false&map_attribute=ROADVIEW&screenMode=normal



4. 주상절리

사진으로 보기에는 그다지 인상적이지는 않았지만...내가 갔을때는 파도가 높아서 부서지는 파도가 매력적이였던 기억.

바로 옆에 있는, 롯데/하얏트 등등 모여있는 예쁜 호텔들과 중문 해수욕장까지 둘러보고 오면 나름 관광 코스~ ^^

이렇게 잔잔한 날보다는 파도치는 날이 훨씬 멋지다!

http://local.daum.net/map/index.jsp?cx=365936&cy=53410&level=3&panoid=1450823&pan=244.41837768489216&tilt=26.403805058945455&map_type=TYPE_MAP&map_hybrid=false&map_attribute=ROADVIEW&screenMode=normal


5. 비자림

울창한 비자나무 숲. 산책 코스로 좋다~ ^^;

아래는 비자림의 끝에 있는 새천년비자나무...일껄? -_-a

이게바로 새천년 비자나무~

http://local.daum.net/map/index.jsp?cx=454985&cy=121474&level=4&panoid=1885499&pan=94.6957967845238&tilt=-7.85429644158503&map_type=TYPE_MAP&map_hybrid=false&map_attribute=ROADVIEW&screenMode=normal


6. Daum

ㅋㅋㅋ 울 회사~
아는 얼굴도 많이 보이네~~

석대표님 수줍은 만세;;; 저 옆에는 머리에 꽃 꼽은건가-_-

사장님~ 나이스 샷~ ㅋㅋㅋㅋ

난 이때 서울 출장이였음 ㅠ ㅠ



7. 우리집

올해 초에 이사온 우리~~집! ^^;

복층! 게다가 마트 바로 앞이야~ >_<)/

http://local.daum.net/map/index.jsp?cx=379407&cy=121088&level=3&panoid=1983508&pan=3.159794876730075&tilt=-16.37704364415604&map_type=TYPE_MAP&map_hybrid=false&map_attribute=ROADVIEW&screenMode=normal


8. 로드뷰 찍는 사람  그림자;;

로드뷰는 3가지 방법으로 찍는다고 한다.

차가 갈 수 있는 곳은, 차 위에 카메라를 올리고 찍고..
차가 못가는 골목길은, 서서타는 이륜 전동차?를 타고 찍고...
사람이 걸어갈 수 밖에 없는 곳은, 촬영장비를 어께에 메고-_- (머리위에 카메라가;;) 찍는단다..

아래는, 사람이 어께에 메고 찍은 것으로 보이는 그림자ㅋㅋ

쵸큼 멋진듯?! 시선이 집중될거 같다 ㅋㅋ

http://local.daum.net/map/index.jsp?cx=491864&cy=124825&level=5&panoid=1453882&pan=307.3905251016283&tilt=43.11507408359446&map_type=TYPE_MAP&map_hybrid=false&map_attribute=ROADVIEW&screenMode=normal



잠깐 휙 둘러봤는데...울 회사 서비스라서 하는 말은 아니고..
정말 잼있다ㅋㅋ

우리 동네 보는 재미가 쏠쏠하네~ ^^

고향 집도 로드뷰 제공되면 어릴때 놀던 놀이터도 가볼텐데~~
And
prev | 1 | 2 | 3 | 4 | 5 | 6 | ··· | 23 | next