473,406 Members | 2,619 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Replace word

Hi there. Need some experts here. I have a file that contains a few unrelated words such as "[IMAGE]", "[FORM NOT SHOWN]","[TABLE NOT SHOWN]" words in a few locations. I have try to search and delete all of these words. For example:

A file contains:
[IMAGE] [FORM NOT SHOWN] Virtualization allows a platform to run multiple operating systems and applications in independent partitions or "containers." [TABLE NOT SHOWN] One physical compute system can function as multiple "virtual" systems. [IMAGE] Vanderpool Technology can help improve future.

My simple code like this:
Expand|Select|Wrap|Line Numbers
  1. $_ =~ tr/^[IM.+AGE]$/ /d;
I get:
FOR NOT SHOWN
Virtualization allows a platform to run multiple operating systems and applications in independent partitions or "containers" One physical compute system can function as multiple "virtual" systems Vanderpool Technology can help improve future

which all the I,M,A,G,E, and full-stop gone.

I want:
Virtualization allows a platform to run multiple operating systems and applications in independent partitions or "containers." One physical compute system can function as multiple "virtual" systems. Vanderpool Technology can help improve future.

Plese let me know if you have solution on it.

Best wishes,
Sep 14 '06 #1
1 1944
Hi,

How about this:
Expand|Select|Wrap|Line Numbers
  1. my $string = '[IMAGE] [FORM NOT SHOWN] Virtualization allows a platform to
  2.  run multiple operating systems and applications in independent partitions
  3.  or "containers." [TABLE NOT SHOWN] One physical compute system can
  4.  function as multiple "virtual" systems. [IMAGE] Vanderpool Technology can
  5.  help improve future';
  6.  
  7. $string =~ s/\[[A-Z\s]+\]\s//ig,
  8.  
  9.  
  10. print $string;
  11.  
This would search for any occurrence of "[SOME TEXT IN UPPERCASE] " and delete it.
Sep 16 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: - ions | last post by:
Hi, i would like to know how to replace every char in a string with a certin given char using the String.replace(char oldChar,char newChar). I would like to replace all letters with an underscore...
2
by: Daniel | last post by:
I use an Access database to basically take data exports, import them, manipulate the data, and then turn them into exportable reports. I do this using numerous macros, and queries to get the data...
1
by: adam lital | last post by:
Hi, I have word document and i want to replace a specific text with a bookmark using code. Example: in the document i have the text and i want to replace this to a bookmark called ClientName....
1
by: James Vitale | last post by:
Using vb asp.net 1.1 I'm doing a word automation on a doc file and trying to do a find and replace. My existing code works fine except that it doesn't find and replace in the header. My code...
4
by: lucky | last post by:
hi there!! i'm looking for a code snipett wich help me to search some words into a particular string and replace with a perticular word. i got a huge data string in which searching traditional...
3
by: Craig | last post by:
Hi I'm having some troubles getting my regex to work. I have a string as follows The "quick and brown" fox "jumped over the" lazy dog. The output should be as follows: The "quick and brown"...
1
by: Michael Yanowitz | last post by:
Hello: I am hoping someone knows if there is an easier way to do this or someone already implemented something that does this, rather than reinventing the wheel: I have been using the...
2
by: Ola K | last post by:
Hi guys, I wrote a script that works *almost* perfectly, and this lack of perfection simply puzzles me. I simply cannot point the whys, so any help on it will be appreciated. I paste it all here,...
1
by: Curious | last post by:
I'm working on a word replacement program in .NET. I have a list of words spelt in American English and need to replace them with translated British spelling while keeping the upper or lower cases...
12
by: implement | last post by:
Hi all! I try to code my own version of replace but it doesn't work. I hope somebody can help me out. It only replaces the first char!. Why I don't use the public string.replace function?...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.