Author Topic: Find & Replace with wild card characters  (Read 10210 times)

0 Members and 1 Guest are viewing this topic.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10386
Find & Replace with wild card characters
« Reply #15 on: July 13, 2005, 10:41:42 PM »
http://new.cadalyst.com/code/browseyear.cfm?fullyear=2005

Adjust Text for All Drawings in a Directory by Andrzej Gumula, p.0
Adjust Text for All Drawings in a Windows Directory, including title blocks, drawing notes, etc.

Code: [Select]
;;;CADALYST 04/05 Tip2028:  Replace Text In Dwgs.lsp      Adjust Text for All Drawings in a Directory (c) 2005 Andrzej Gumula

;;; [c]2004 Andrzej Gumula, Katowice, Poland
;;; e-mail: a.gumula@wp.pl
;;; This routine repleces text in dwg files from the selected folder.
;;; Also accept subfolders.

 (setq Tmp (list "This routine replace text in dwg files from the selected folder."
"Options:"
"-match case: allow for uppercase and lowercase alphabetic characters"
"-find whole words only: if active the routine analyse only whole words"
"-find in subfolder: if active the routine find dwg files also in subfolders of selected folder"
"-model space: if active the routine analize text entities only in model space"
"-paper space: if active the routine analize text entities only in paper space (layouts)"
"-both space: if active the routine analize text entities only in model and paper spaces"
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CADaver

  • Guest
Find & Replace with wild card characters
« Reply #16 on: July 14, 2005, 08:18:32 AM »
Quote from: tcdan
In any case I'm not too concerned whether or not you can use the find/replace function this way cuz it sounds like you could write a lisp to do the same thing a wild card character could do within find/replace by properly using wcmatch.
I guess that was my point of confusion all along, the wildcard wasn't gonna help in any of the practical applications I could envision.

tcdan

  • Guest
Find & Replace with wild card characters
« Reply #17 on: July 14, 2005, 05:57:04 PM »
CAB - just looking at the description of that routine, it looks awesome - haven't tried it yet. . .


CADaver
Quote from: CADaver
\P is the code for a hard line feed; "My name\Pis CADaver"

I tried using \P in 2005 and it didn't seem to work.


Quote from: I
It also helps me catch return characters. If i have a 2-line mtext object that reads:
"My name
is CADaver"
I cannot search for "My name is CADaver" if their is a line return character between "name" and "is". I CAN search for "My name" and "is CADaver", but this is not useful when I want to replace the whole string of text with something new (which I actually do).

OK, I take it back.  You CAN search mtext with line returns quite intuitively by simply pretending the lines wrap together.  So
"My name
is CADaver"
could be found by searching for "My nameis CADaver".  And if you wanted to search for "My name" you would simply uncheck the 'search for whole words option'.

Jeff_M

  • King Gator
  • Posts: 3973
  • C3D user & customizer
Find & Replace with wild card characters
« Reply #18 on: July 14, 2005, 06:56:11 PM »
Dan, note that \p & \P are 2 different things.....

tcdan

  • Guest
Find & Replace with wild card characters
« Reply #19 on: July 14, 2005, 07:41:33 PM »
Quote
Dan, note that \p & \P are 2 different things.....

I edited my post - I meant to type \P.  Neither \P nor \p work.

Jeff_M

  • King Gator
  • Posts: 3973
  • C3D user & customizer
Find & Replace with wild card characters
« Reply #20 on: July 14, 2005, 08:03:27 PM »
OK, you're right! Just shows one more reason why I use my own rather than Find. I just made a test Mtext. In it I put "THIS IS A TEST", then I copied it and edited it to place a hard return just prior to the "A". Then, using Find, I did a replace all with "THIS IS A TEST" & "TEST" as my for & replace lines......BOTH Mtext objects were modified! It completely overlooked the line feed....BAH!

CADaver

  • Guest
Find & Replace with wild card characters
« Reply #21 on: July 15, 2005, 08:48:31 AM »
hmmm... still running R2002 here, so that may be the difference.  But it won't jump a hard return for me.

How did you enter the hard return?

Jeff_M

  • King Gator
  • Posts: 3973
  • C3D user & customizer
Find & Replace with wild card characters
« Reply #22 on: July 15, 2005, 01:03:50 PM »
I'm using 2002 also. I used the Enter key in the Mtext Editor.
And here's what LIST returns on the edited one.

                  MTEXT     Layer: "0"
                            Space: Model space
                   Handle = 2C
Location:        X=   8.5501  Y=   5.5778  Z=   0.0000
Width:              4.1357
Normal:          X=   0.0000  Y=   0.0000  Z=   1.0000
Rotation:                0
Text style:      "Standard"
Text height:        0.2000
Line spacing:    Multiple (1.000000x =    0.3333)
Attachment:      TopLeft
Flow direction:  ByStyle
Contents:        THIS IS \PA TEST

CADaver

  • Guest
Find & Replace with wild card characters
« Reply #23 on: July 15, 2005, 01:25:43 PM »
Are you using the infernal ... ummm... internal editor?  cuz' it won't jump the line feed for me.

tcdan

  • Guest
Find & Replace with wild card characters
« Reply #24 on: July 15, 2005, 01:49:57 PM »
Jeff - 2005 gives the same listing for the contents "THIS IS \PA TEST"

Quote from: CADaver
Are you using the infernal ... ummm... internal editor? cuz' it won't jump the line feed for me.


I tried with notepad and with internal editor - same results.

tcdan

  • Guest
Find & Replace with wild card characters
« Reply #25 on: July 15, 2005, 01:54:55 PM »
Quote from: CADaver
Are you using the infernal ... ummm... internal editor? cuz' it won't jump the line feed for me.


OK - I might have found the difference.  If you place a space before inputting a line feed, CAD will find the text as it looks.  So, you can search for
"This is
a test."
in find/replace IF there is a space (inputted with the spacebar) between 'is' and 'a' even if there is also a line feed.

So CADaver, do you input a space before going to the next line, because I do not.

CADaver

  • Guest
Find & Replace with wild card characters
« Reply #26 on: July 15, 2005, 05:54:03 PM »
huh, whud ya' think o' that?  I never place a space prior to the line feed, but I may start.  How'd you happen upon that?

Really wierd thing: if you place text "this is \Pa test", and then REPLACE "this is a test" with "eeeeeeeeeeeeee", the result on screen stilll has the line feed in the same spot, "eeeeeeee\Peeeeee"

tcdan

  • Guest
Find & Replace with wild card characters
« Reply #27 on: July 15, 2005, 07:22:20 PM »
Strange indeed. . . I might ask why you came across THAT in return to your question to me. . .  I don't really know how I happened upon it honestly - but I don't think it's going to help me put a space before I press enter.