473,395 Members | 1,696 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,395 software developers and data experts.

Removing dots - please help me out

Could you please help me out with regular expressions. I'm trying to
write a perl script that proccesses some text, and i'm stuck at the
following:

need to remove from the text
1. dots followed by space & words starting with lower case letters
2. dots followed by only by words starting with lower case letters

ie

"pure text here bla bla bla. more text follows" --> changes to
"pure text here bla bla bla more text follows"

and

"pure text here bla bla bla.more text follows" --> changes to
"pure text here bla bla bla more text follows"

Need to remove just the dots, not letters.

No matter how hard i tried, i could not make it work. Tried various
things eg $line =~ s/\. (?=[a-z])/ /g; I'd really appreciate your
help, it's a must do and dont have anyone else to help out.

Thanks in advance.
Jul 19 '05 #1
3 4218
Aristotle wrote:
need to remove from the text
1. dots followed by space & words starting with lower case letters
2. dots followed by only by words starting with lower case letters

ie

"pure text here bla bla bla. more text follows" --> changes to
"pure text here bla bla bla more text follows"

and

"pure text here bla bla bla.more text follows" --> changes to
"pure text here bla bla bla more text follows"

Need to remove just the dots, not letters.

No matter how hard i tried, i could not make it work. Tried various
things eg $line =~ s/\. (?=[a-z])/ /g;


You seem to be close, but since the dot may or may not be followed by
a space, you'd better say so:

s/\. ?(?=[a-z])/ /g;
---------^

HTH

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Jul 19 '05 #2
Thanks, it does seem to work correctly.
However, there are still some dots that are not being removed,
for example when there is a 'return' after the dot:

"Asthma in children of sycotic parents ( Nat .
s ) Spasms of the glottis with clucking in the larynx ; air "

Ofcourse i'm using first
$line =~ s/\n//g;
in order to remove the return characters and then
$line =~ s/\. ?(?=[a-z])/ /g;
but these dots still escape.

Any ideas why it doesnt work ?
Gunnar Hjalmarsson <no*****@gunnar.cc> wrote in message news:<HVH5c.52520$mU6.
You seem to be close, but since the dot may or may not be followed by
a space, you'd better say so:

s/\. ?(?=[a-z])/ /g;
---------^

Jul 19 '05 #3
Please ignore my last message about some dots after returns, escaping the regex.
It was my mistake, needed to re-apply the regex a second time at a different point.
Thnx
Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: John Smith | last post by:
How would I strip all <a href=""></a> tags from a block of text using ASP? I assume you would need to find "<" and ">" tags, but I am not sure how you would actually remove it from the text. Any...
2
by: Vitali Stolpner | last post by:
hi all, im trying to make a program in c++ (trying to make textris, im just a beginner so im not using anything fancy, just text) and the problem that i run into is the cursor flashing all over the...
8
by: Peter O'Reilly | last post by:
I have an HTML form with a textarea input box. When the user conducts a post request (e.g. clicks the submit button), an HTML preview page is presented to them with the information they have...
66
by: Cor | last post by:
Hi, I start a new thread about a discussion from yesterday (or for some of us this morning). It was a not so nice discussion about dynamically removing controls from a panel or what ever. It...
3
by: Chantal | last post by:
Hello everybody, I'm relatively new to javascript + DOM so I've a question : I'm removing <div> elements in DOM with javascript. It works perfectly in Firefox and Opera : I mean the DOM is...
9
by: Rob Meade | last post by:
Hi all, I have an array of lets say 10 items, I now want to remove an item, lets say from somewhere in the middle, based on one of the element values equalling a value I specify - is there a...
5
by: Gregc. | last post by:
Hi Is this correct to clear select items? function(sel){ var selected = sel.options.text; var name=sel.name; (i=1; i<sel.length=0,i++){ sel.options.length=0;}
1
by: James0816 | last post by:
Hello, I just found this site...and just in time to as my frustration builds. I am trying to add a row of dots to my page using javascript but cannot seem to get it to work. I know I have to use...
10
by: sophie_newbie | last post by:
Hi, I'm trying to write a piece of code that spawns a thread and prints dots every half second until the thread spawned is finished. Code is something like this: import threading class...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.