Wikipedia:Reference desk/Archives/Science/2006 June 30
| ||||||||
The page you are currently viewing is an archive page. Whilst you can leave answers for any questions shown below, please ask new questions at one of the pages linked to above. This will insure that your question is answered more quickly. | ||||||||
|
Energy
[edit]If a piece of matter had its particles vibrated or oscillated to the speed of light would it turn into energy?
- Such an action is not possible within the framework of current physics; the laws of physics will not be able to predict the outcome. — Knowledge Seeker দ 05:07, 30 June 2006 (UTC)
- Energy isn't any particular thing. It's just a quantity you get by adding up all these different terms which happens to remain the same no matter what happens (it's "conserved"). If someone points at something and asks "What's that?", the reply "It's energy." would be nonsense. It could be a mass in a gravitational field or a charge in an electric field or something spinning or stretched or many other things, all of which have energy, but it can't just be energy. Am I making any sense? —Keenan Pepper 06:11, 30 June 2006 (UTC)
- I suppose the questioner could be using 'energy' as a shorthand for 'photons'..? As Knowledge Seeker says, you can't force matter to move at the speed of light. TenOfAllTrades(talk) 15:05, 30 June 2006 (UTC)
Thank You Keenan also yes I meant energy as photons. Tahnk You
- However, if you're looking at anything at all, you are most directly perceiving energy, not mass; our entire visual perception is based on transfer of electromagnetic energy (which is moderated by the particle known as the photon). And besides, mass is energy, energy is mass, as far as is now known. details are pending (see next nobel prize in physics)
Waveguide modes
[edit]Hi, Are the EM modes (eigenfunctions) of a simple conductive isotropic waveguide orthogonal? I know they form a complete basis, but I'm not sure about their orthonormality. I'd appreciate an explanation of how to determine this property too, if you have time. Thanks --Bmk 06:17, 30 June 2006 (UTC)
- Hmmm, you haven't received a reply yet, so I suspect that this question may be too specialised for the Wikipedia reference desk. However, the people on the mathematics reference desk might be a better bet; they may not be familiar with the specifics of waveguide antennas but they are pretty damned hot on math; if you can show them the eigenfunctions they might be able to determine how to show whether they're orthogonal or not. Straining at the very back of my memory I do remember the concept of eigenfunctions and normal bases for matrices, but I'm afraid computation of such dropped out of memory roughly a decade ago. All the math I do these days is about integers :) --Robert Merkel 02:36, 1 July 2006 (UTC)
- Posting on the math forum is a good idea, but I think people will yell at me about double posting. --Bmk
- I only object to people intentionally posting to multiple boards. If you post to one and are told to repost elsewhere, I have no problem with that. StuRat 01:47, 12 July 2006 (UTC)
History of locks
[edit]In the course of my editing work, I recently removed mention of a keyhole in a story set in India in the time of the Buddha, on the assumption that they wouldn't have had such things then. However, I haven't been able to ascertain when the first locks (with keyholes) would have been invented. One of the various Wikipedia articles on locks suggests they might have been around in "ancient Rome" but that doesn't help much. So I guess my question is when, roughly, was the lock invented?--Shantavira 07:36, 30 June 2006 (UTC)
- It's certainly possible there were locks in India in Gautama Buddha's time (5th century BCE), but it doesn't seem especially likely. The oldest known lock is about 4000 years old [1]. They were known in the Persia, Egypt, and China by about that time [2], but it's not clear how common they were. That second page, though, does include some descriptions and photos of the locks and keys that would have been common in that time, if you would like to include it. -- Plutor 12:04, 30 June 2006 (UTC)
- I need to research, but my memory is that China introduced push-key locks. There's no hole that goes all the way through. The Romans introduced turn-locks. They were one-sided. Again, there's no hole that goes all the way through. A very recent (1700's if memory serves) invention was the two-sided lock - which has a hole that goes all the way through. I'm assuming that the story requires a two-sided lock. So, I'm going to see if I can figure out when the first two-sided lock was invented and then when it became popular. --Kainaw (talk) 12:57, 30 June 2006 (UTC)
Peeing into bleach-filled toilet...
[edit]I just urinated into my toilet, having forgotten that I'd poured ordinary household bleach into it earlier this morning. As soon as my pee hit the water, a white precipitate was immediately formed, along with a nasty-smelling gas (not ammonia - I know what that smells like).
Anyone have any ideas as to the nature of the chemical reaction that just took place? I seem to remember covering this at school but it was a long time ago now. Thanks.
EDIT: The bleach contains sodium hypochlorite. --Kurt Shaped Box 13:25, 30 June 2006 (UTC)
- It's probably a mixture of many nasty things, chloramine and chloroform possibly among them. —Keenan Pepper 13:42, 30 June 2006 (UTC)
- Here's a report on an industrial accident involving mixing of urea (a major component of urine) and sodium hypochlorite [3]. Hypochlorite can react with urea to form (among other things) the reactive compound nitrogen trichloride. TenOfAllTrades(talk) 15:03, 30 June 2006 (UTC)
toxic exposure
[edit]could someone please advise how toxic a printer is if it sits directly on your desk and the vents are facing you? the printer is a hp lazerjet 4250dtn. the printer is directly level to my face and the fans/vents are 1 1/2' away from my face. many thanks.
- You may find this study interesting. Also, when searching, you'll get a lot more hits using "laserjet" instead of "lazerjet". --Kainaw (talk) 14:23, 30 June 2006 (UTC)
- I suggest reading the warning label on an ink cartridge and/or the packaging for the cartridge, since that will be the source of most of the toxins. StuRat 14:25, 30 June 2006 (UTC)
- A LaserJet uses toner, not ink. I've just looked that a toner cartridge and the box containing it and there are not warning labels of any kind. --LarryMac 14:38, 30 June 2006 (UTC)
- "Would not ink, by any other name, stain as badly ?" StuRat 15:15, 30 June 2006 (UTC)
Go to the HP MSDS site and get a copy of the MSDS (Materials Safety Data Sheet) for your toner cartridge. many thanks for eveyones help. it was very much appreciated.
- Some laser printers produce noticeable amounts of ozone. The claim is that the HP 4250DTN "generates virtually no ozone emissions". The toner probably isn't a big deal unless it is sprayed into the air. Notinasnaid 17:44, 30 June 2006 (UTC)
- There is allegedly no ill effect from exposure to high amounts of toner material. I used to work in a printshop where the dust from toner and paper would be so thick in the air you could see it and collect it up off of flat surfaces. The only warning they gave us was to not stare at the paper and try to read it as it goes by, it will drive you mad by clouding your head with fragments of information. Whether that is true remains to be seen, I wasn't exactly normal to begin with.
- I'd be a little worried about fine dust, even if it is not toxic in itself - you probably don't want to sit in the exhaust vent. What about a piece of card shaped to to angle the flow elsewhere? Trollderella 20:31, 30 June 2006 (UTC)
Wait, you're worried that the exhaust fan is going to kill you with toxic fumes? Are you serious? --mboverload@ 02:36, 1 July 2006 (UTC)
Well, why not. A lot of stuff will kill you or give you cancer if you breathe it in on a regular basis for a few years.--Bmk 07:02, 1 July 2006 (UTC)
- This is an office. An office printer. It's a printer. Printers don't kill people. If they did, they would have a warning label I assure you =D --mboverload@ 09:31, 1 July 2006 (UTC)
Counseling vs. Therapy
[edit]In the context of mental health, what is the difference between seeing a counselor and seeing a therapist, or being "in counseling" vs. being "in therapy"? Thanks, TacoDeposit 15:24, 30 June 2006 (UTC)
- Well, counseling redirects to psychotherapy, and, reading the article, counselling seems to be a subset of therapies for psychological ailments. I think that the lay uses of the terms are confusing, and not always applied in the same way that professionals would use them. Note also that there are many different professional bodies that govern practitioners, and that they overlap in their areas of practice. Trollderella 19:12, 30 June 2006 (UTC)
Blood Donation
[edit]Are all blood donors screened for hepatitis c virus?
According to the CDC (HCV fact sheet), as of July 1992, all blood donations in the US are required to be screened for Hepatitis C.
Since that time, the CDC reports that incidence of HCV transmission due to blood transfusions is less than one in 2,000,000 units of blood (which to me still seems kind a high, but ok). --Bmk 15:56, 30 June 2006 (UTC)
- Well, risk is subjective, but that's really not high when you consider other hazards you face every day. Trollderella 18:58, 30 June 2006 (UTC)
- I suppose. It's probably more dangerous to walk around in your bathroom. Or to drive a car --Bmk 19:11, 30 June 2006 (UTC)
- I hope this doesn't sound like a nit-pick, but I don't think I agree that risk is subjective. To the contrary, risk is a mathematical thing that can be calculated if the inputs are known. Sometimes the inputs are off, so the calculation is off, but that is still an objective thing with associated error, it is not subjective. What IS subjective is people's perception of risk and whether they think taking the risk is worth it for the expected gain. There was more than one discussion here just this week about whether someone found the risk of HIV infection from vaginal sexual intercourse with an infected woman was too high or not. There were people saying that a 1 in a 1,0000 chance of dying was OK to them, which I personally find amazing, but that is where subjectivity comes in.
- On the objective side, I think a blood transfusion is more deadly than dying walking across your bathroom or riding in a car. Here is my math:
- There are almost 300 million people in the US. I will assume they make an average of 1.8 trips per day (can't find a soure so this is a guess) - that means 538 million car trips a day in the US. According to this there are 118 automobile deaths each day in the US. That means your odds of dying in a car are 1 out of every 4.6 million trips.
- On the other hand, in a transfusion, you typically receive 3-5 units of blood - source (Pdf). I'll use 4. That means your odds of getting hepatitis from a blood transfusion are 4 in 2 million or 1 in 500,000. Therefore, a blood transfusion is riskier by at least 9x (probably more since that is only the risk of dying from HPC and does not include HIV or other nasties). In short, drive carefully so you don't need a blood transfusion - they are dangerous!
- According to this motor vehicle accidents kill more people each year than bath-tub drownings and falls combined. Since I will assume that everyone who has a motor vehicle definitely has a bath-room, that means that motor vehicles must be more dangerous than bathrooms, so there is no reason to do any math on the bathroom scenario.
- There are almost 300 million people in the US. I will assume they make an average of 1.8 trips per day (can't find a soure so this is a guess) - that means 538 million car trips a day in the US. According to this there are 118 automobile deaths each day in the US. That means your odds of dying in a car are 1 out of every 4.6 million trips.
- Johntex\talk 02:57, 1 July 2006 (UTC)
- On the third hand, if you have any hands left, you can stay out of your car anytime you want, but when you're you're lying on the table with your life ebbing away by the second, you don't say, wait! Doctor! I might get hepatitis C! You say stick the damn needle in and start pumping! Blood transfusion is by its very nature a risky process; you're pumping a foreign substance directly into your circulatory system.
- On the gripping hand, blood transfusions are typically only given if there is something seriously wrong with you for which the chances of dying are typically well over 1 in 500,000. The risks of most medical procedures are far higher, for instance; a simple tonsillectomy apparently gives you somewhere between a 1 in 16,000 and 1 in 35,000 risk of dying in the process. --Robert Merkel 06:22, 2 July 2006 (UTC)
- On the third hand, if you have any hands left, you can stay out of your car anytime you want, but when you're you're lying on the table with your life ebbing away by the second, you don't say, wait! Doctor! I might get hepatitis C! You say stick the damn needle in and start pumping! Blood transfusion is by its very nature a risky process; you're pumping a foreign substance directly into your circulatory system.
- I suppose. It's probably more dangerous to walk around in your bathroom. Or to drive a car --Bmk 19:11, 30 June 2006 (UTC)
destroying the reference desk?
[edit]can someone give a list of pros and cons for demolishing the entire reference desk with this new system already in effect on this page? and why pick on WP:RD/s? If you're going to maim a reference desk, why not miscellaneous or languages? why pick the most popular?--71.247.107.238 16:05, 30 June 2006 (UTC)
- Please stop trying to cause a problem where there is none. Nothing is demolished. Everything is still working. And transcluding fixes a backup problem as discussed on the talk page just above where you commented. -- Plutor 17:17, 30 June 2006 (UTC)
I'm sorry, can you please explain what it is you're complaining about? User:Zoe|(talk) 01:58, 1 July 2006 (UTC)
- The proposition that all entries are removed after a day, instead of the current week. Philc TECI 02:01, 1 July 2006 (UTC)
To clarify, items aren't "removed from the desk" after a day. The science reference desk is now transcluded - that is, each day's questions are now on a separate sub-page, with a week's worth of subpages listed on the main Science Reference Desk page where they may all still be read. The reason it's only on the science desk is that this was only proposed a week or so ago (by me) and is being implemented as a trial on the science desk. if it's successful it will eventually be used on other desks. The science desk tends t be the one used for such trial runs (such as the "featured question" trial which is still going on, I think). Grutness...wha? 03:11, 1 July 2006 (UTC)
- Another reason for choosing the Science RD for a trial is that it is the one which has had its archiving fail most often. (There currently aren't archives for a number of days out of the last 4 or 5 months due to failures because of the size of the pages. Transcluding each day's section should avoid the size failures.) -R. S. Shaw 04:33, 1 July 2006 (UTC)
- someone really should <includeonly> the reference desk header into each section, otherwise people won;t have any way to get back to the main reference desk after they answer the question--205.188.116.138 01:34, 3 July 2006 (UTC)
enlight me with a light......
[edit]in india its called a tube light but elsewhere i suppose its called a gas tube.its in every house,it lights up the house bright with its initial flickers and it contains an inert gas;from what i knw it contains neon or argon.so anyone can please help me in knowing how such a tube light works?i have also heard that it uses a choke and how does that help in its working?????i'll be glad if anyone can help me in finding the answer to the working of an everyday use equipment!
- Tube lamp and tube light are now redirects to fluorescent lamp. I have not heard it called a gas tube anywhere. Good luck — Pekinensis 16:53, 30 June 2006 (UTC)
- Neon lamp? When you apply a high voltage on the gas, it becomes ionised: that is, some outer electrons of the atoms are moved away from atoms, so instead of many neutral atoms you have charged particles -- free electrons and positive ions. How it happens? Say, one electron was blown away from the atom. Then it, a charged particle, accelerates by the electrical field. Gains energy. Strikes another atom. And blows its electron away. So, number of electrons increases as far as possible. A flow of charged particles is an electric current. Ok. The light comes from -- when electron falls on the ion, forming an atom again, the excessive energy is emitted as light. -- but it's pretty not accurate. ellol 10:55, 1 July 2006 (UTC)
Yin & Yang + 5 Elements Theory
[edit]Is there a basis on which Chinese doctors depend when catogorizing body organs and symptoms as well as foods into Yin or Yang or one of the 5 elements in TCM ? Also is this catogorization - genarally - accurate ? Hhnnrr 18:06, 30 June 2006 (UTC)
- Western and Chinese traditions start from different philosophical assumptions, and use different methodologies. They agree on some points (for example, the beneficial effects of acupuncture in some cases) and not in others. The question of 'accuracy' depends on your perspective. Trollderella 19:03, 30 June 2006 (UTC)
- A side question about acupuncture - haven't there been studies that seem to indicate that placebo acupuncture is just as effective as the real thing? Not that it isn't effective - it was still effective, but I seem to remember that the study indicated that it may be a psychological effect, rather than a physiological one. --Bmk 19:23, 30 June 2006 (UTC)
- Start with Yin and yang, Five elements (Chinese philosophy), and Chinese traditional medicine. --Ginkgo100 talk · contribs 20:05, 30 June 2006 (UTC)
- Western and Chinese traditions didn't necessarily start from different philosophical assumptions: see Four humours for the European medical tradition predominant for over a thousand years. That theorised a balance between four basic elements, was well-regarded in its day, and successfully categorised diagnoses and treatments in its own terms. I have a strong feeling that any "n universal principles" theory of medicine can be "accurate", as is an [[Ad hoc] explanation that can be made to fit all observations perfectly Malcolm Farmer 11:01, 1 July 2006 (UTC)
Corn cob
[edit]Why is the number of rows of seeds in corn cob is always even in number and never otherwise.
- I don't know - did you try to corn article? Trollderella 18:57, 30 June 2006 (UTC)
- "Why ears of corn always have an even number of kernel rows is basic biology, says Dale Farnham, agronomy. Cell division always occurs in multiples of two. So most ears of hybrid corn will have 16 to 20 rows of kernels. If stress occurs early in development, there may be only 12." says this [4]. 128.197.81.181 19:10, 30 June 2006 (UTC)
- Hmmm...doesn't that also require that "kernel-generating cells" also all divide the same number of times? I mean, if you start with one cell, which divides into two, then only one of the two resulting cells divides, which leaves you with three kernels; unless the kernel-cells all divide the same number of times, it doesn't seem like an even number of kernels is guaranteed. I'm going on almost zero information here, but I'm not sure I understand the full explanation above. --Bmk 19:19, 30 June 2006 (UTC)
- Assuming cell divisions take place at a regular rate, or that changes in the rate affect all cells equally, then all cells would divide at about the same time. --Ginkgo100 talk · contribs 20:00, 30 June 2006 (UTC)
- Fair enough --Bmk 20:19, 30 June 2006 (UTC)
- Assuming cell divisions take place at a regular rate, or that changes in the rate affect all cells equally, then all cells would divide at about the same time. --Ginkgo100 talk · contribs 20:00, 30 June 2006 (UTC)
- Hmmm...doesn't that also require that "kernel-generating cells" also all divide the same number of times? I mean, if you start with one cell, which divides into two, then only one of the two resulting cells divides, which leaves you with three kernels; unless the kernel-cells all divide the same number of times, it doesn't seem like an even number of kernels is guaranteed. I'm going on almost zero information here, but I'm not sure I understand the full explanation above. --Bmk 19:19, 30 June 2006 (UTC)
- Citing "basic biology" explains nothing. Cell division can yield absolutely any number, depending of any parameter. The strong parameters are linked with those questions : if the growth is regular, what is the regulatory agent ; when does the growth (in number of rows) end and why. Take note that we have five fingers because bones get divided by two, which looks very basic ... but four of them merged in the thumb (a long time ago it seems). --DLL 20:22, 30 June 2006 (UTC)
- Alright, I'll try again. "A corn ear is actually an inflorescence that produces nearly 1,000 female flowers. These flowers, or potential kernels, are arranged in an even number of rows (usually from 8 to about 22 rows). Row number is always an even number because corn spikelets are borne in pairs, and each spikelet produces two florets: one fertile and one sterile. Stress at a particular stage in development could theoretically produce an ear with an odd number of rows - but I believe if you looked under a microscope, you would find an unseen row that failed to develop fully. Most things in nature have an even number of rows or lines. Watermelon has an even number of stripes, cantaloupe, etc. Think of it this way. One cell divides into 2 - as cell division continues, there is always an even number." from [5]. 128.197.81.181 20:51, 30 June 2006 (UTC)
- Hmmm...then why are four leaf clovers so rare? Johntex\talk 02:25, 1 July 2006 (UTC)
- I would guess three leaves is better design for the clover. Archetictually, it seems stronger. I don't know how to spell archetect. — The Mac Davis] ⌇☢ ญƛ. 15:15, 2 July 2006 (UTC)
Medication Methods
[edit]Would it be possible to specify the scientifically proven methods through which one can benefit from medication ? My guess would be : through the mouth ( eaten or drunk ) , through the vein , through the anus / vagina , inhaling , anointment . ( Sorry , I dont know the right names ) I would like a correct list and a reference if possible .. Thanks Hhnnrr 18:24, 30 June 2006 (UTC)
- Just about anything you can think of has been tried, and all of them are used for one drug or another.
- You can stick a needle anywhere (into muscle, the abdomen, subcutaneous fat, a vein, an artery, the eyeball, the cerebrospinal fluid, etc.). You can apply stuff topically anywhere you can put a bandage, swab, or eyedropper (skin, eyes, nose, ears, hands, feet, scalp, etc.). Plus, anywhere you can stick an endoscope or other probe is a route to deliver medication and treatment (esophagus, anus, vagina, etc.)
- Different medications will be delivered in different ways for different reasons. Some drugs will pass through the skin, some won't. Some can cross the blood-brain barrier. Some aren't stable in acidic environments, so don't work if ingested. Some drugs you want to deliver quickly, some you want to deliver over an extended period of time. TenOfAllTrades(talk) 18:31, 30 June 2006 (UTC)
Thanks , But would it be possible to sumerize these methods ? My goal is to exclude any method that has not been proven useful . So can the list look something like this ? : 1- ingestion 2- inhalation 3- skin penetration 4- probing ( ? ) 5- anointment Any help from a specialist ?? Hhnnrr 18:55, 30 June 2006 (UTC)
- Well they're all useful for different things. The utility of the method varies depending on the purpse of the medication. Trollderella 19:09, 30 June 2006 (UTC)
Yes I understand they are all useful methods and that they are used in different cases , but my question is : are there other useful methods ( regardless of their uses ) ? Hhnnrr 19:16, 30 June 2006 (UTC)
- Well, it depends on how much detail you want to describe them in. You might want to get hold of a basic medical textbook that should discuss this kind of thing, but it would seem that there are really not other ways to take medicine than injection, inhaling, rubbing / contact with skin, ingesting, or putting in body cavities. I sense that we're not really getting to the root of your question though, do you want to try to ask it in a different way? Trollderella 19:24, 30 June 2006 (UTC)
Thanks , what I'm trying to get to is that wearing a stone - for example - would not be catogorized under any legitiment means of medication ? Since none of the methods above apply to it . Correct me if I'm wrong Hhnnrr 19:41, 30 June 2006 (UTC)
I believe what Hhnnrr is looking for is a single comprehensive, official list of all drug delivery systems currently in use by the western medical establishment. We could try to formulate such a thing by consensus, but I think Hhnnrr wants something from an official link, like from the FDA or something. --Bmk 19:43, 30 June 2006 (UTC)
- I see - comes down to a matter of opinion - some people would think that wearing a stone has beneficial effect, but the mainstream medical establishment and the FDA would not certify it - you probably do want a list of FDA approved devices, I guess. Trollderella 19:46, 30 June 2006 (UTC)
route of administration may be helpful. If you follow the two external links there, you'll see a (non-exhaustive) list of over 111 different routes of delivery that will at least cover the basics and gives some idea of the breadth of the subject. - Nunh-huh 21:14, 30 June 2006 (UTC)
"Through the mouth (eaten or drunk)" ignores one important one - dissolved under the tongue. Several drugs that need to reach the brain are administered this way, since it gets them into the bloodstream (via the large veins that run beneath the tongue) without them having to be injected. this is particularly useful for ones which wouldn't get into the bloodstream if they were digested, due to them being metabolised thoroughly by the digestive system. Grutness...wha? 13:23, 1 July 2006 (UTC)
Females taking Viagra
[edit]What would happen if a woman were to take Viagra? Would her clitoris be... stimulated etc or would there be no effect etc?
Moffo
- Type Viagra in the search box and click on Go. The Viagra article mentions the effects of Viagra in women. Wow! Wikipedia is also an encyclopedia!? I thought it was just a reference desk. --Kainaw (talk) 19:41, 30 June 2006 (UTC)
I do apologise. I had a look at that page but I never saw that section until I did a page search! My apologies once again.
Moffo
- considering that most people here scrable to answer absolutely every question, Kainaw's answer was a little bit withering :) dab (ᛏ) 00:05, 1 July 2006 (UTC)
- I only answer that way once a day. The rest of the time I respond with utter nonsense. It is sort of a lottery - who gets the sarcastic answer of the day! --Kainaw (talk) 00:46, 1 July 2006 (UTC)
- Please try to be a bit more tolerant. I don't think that I'm the only person who finds such treatment of anybody to be uncivil. – ClockworkSoul 02:38, 2 July 2006 (UTC)
- Thank you. --Ginkgo100 talk · contribs 21:08, 2 July 2006 (UTC)
- Please try to be a bit more tolerant. I don't think that I'm the only person who finds such treatment of anybody to be uncivil. – ClockworkSoul 02:38, 2 July 2006 (UTC)
- I only answer that way once a day. The rest of the time I respond with utter nonsense. It is sort of a lottery - who gets the sarcastic answer of the day! --Kainaw (talk) 00:46, 1 July 2006 (UTC)
Ship's bridge - round windows?
[edit]I've noticed that on many ship's bridges, some of the forward-facing windows have a round insert of sorts. The article on ship's bridges doesn't mention it. What is this, and what is it's purpose? this picture shows two of them. This one, on the other hand, only has one, on the left side of the image. Thanks! --192.41.148.220 21:37, 30 June 2006 (UTC)
- It spins to keep the window clear of water and such. It serves a similar function to windshield wipers, as explained here. kmccoy (talk) 21:56, 30 June 2006 (UTC)
- The relevant article is clear view screen. --cesarb 23:59, 1 July 2006 (UTC)
Thanks a lot, you guys rock.
Regex help
[edit]I have a regex problem not covered in any of my CSCI books or any online site I can find. I have a program that converts english to regex to pick out lines from extremely long CSV files. The function it does not do is != (not equal to). I am trying to add this in, but I have to represent "not equal to a phrase" in regex. For example, if I want all lines except the phrase "dog", I've tried "[^d][^o][^g].*" and "([^d]|.)([^o]|.)([^g]|.).*" - but nothing works. I know that [^dog] actually means "not the letter d, the letter o, or the letter g". So, what means "not the phrase dog"? --Kainaw (talk) 21:50, 30 June 2006 (UTC)
(:?!dog)
or some derivative of that? --Sam Pointon 21:58, 30 June 2006 (UTC)
- See also
perldoc perlre
. An alternative is to negate the match (eg,$str !~ /dog/
). --David Iberri (talk) 03:33, 1 July 2006 (UTC)
- Well, Perl is an abomination... but in this case PCREs are necessary. (See [6] for documentation that doesn't require having Perl installed, and [7] for the corresponding Python documentation.) Clearly, "not the phrase dog" cannot be expressed in a regular language (there's no generating grammar for it) so you'll need a Perl-style extension:
^(?!.*dog.*)
will work. However, it's hideously inefficient; a "match is negative" flag on your generated regexps would make more sense. EdC 05:19, 1 July 2006 (UTC)
- Thanks. I don't think this is going to work. When I try anything that has a ? inside of ( and ), all I get is something like "bash: !dog event not found". So, for the != clause, I'm going to have to write a separate program that parses the lines that the existing program spits out. --Kainaw (talk) 00:51, 2 July 2006 (UTC)
- If you get a "event not found", it means you are underquoting. Enclose the argument in single quotes. --cesarb 05:18, 2 July 2006 (UTC)
- Actually, "not the phrase dog" is a regular language; the complement of a regular language is regular, and the language "the phrase dog" is certainly regular. It is just that standard regex implementations do not give a concise syntax for it. It is possible to generate:
([^d]..|.[^o].|..[^g])
will match any three characters that aren't "dog", and you can add more alternatives with anchors (if appropriate) to get other numbers of characters:([^d]..|.[^o].|..[^g]|^..?$)
or even([^d]..|.[^o].|..[^g]|^..?$|....+)
. But the other responders have a point: what possible use is there to actually match "not 'dog'"? Surely you want to react differently in some way to "dog" than to everything else, so just use an if-test (in whatever language) on matching "dog", dealing with a false result however you like. (Evengrep
has-v
.) I might also point out that my first regex will match starting at the 'o' in "dog days". --Tardis 17:46, 3 July 2006 (UTC)
- Actually, "not the phrase dog" is a regular language; the complement of a regular language is regular, and the language "the phrase dog" is certainly regular. It is just that standard regex implementations do not give a concise syntax for it. It is possible to generate:
- The point to matching "not 'dog'" was that I inherited a program from previous programmers here that accepts sql-like queries (eg: select 1,3,6 from users.csv left join accesses.csv on users.1=accesses.1 where accesses.0>'2006-01-01' and accesses.3='backup') and converts them into a single grep regex statement, runs the statement, and prints the resulting csv lines to the screen (which are usually redirected to a file). There are 12 servers here. If wanted to see the accesses of every user except myself, I would have to add "users.0='jordan' or users.0='cook' or users.0='egan' or..." for every single user. It would much easier to simply say "users.0!='kainaw'". --Kainaw (talk) 19:19, 3 July 2006 (UTC)
JustSnipe.com Looks Dodgy...
[edit]One of the letters in ComputerActive magazine, suggested www.justsnipe.com as a free way to do automatic sniping - surely registering your eBay login details with some seedy-looking site is a bad idea? Why did ComputerActive publish it?
- You'd be better off asking the editors of ComputerActive magazine rather than us. However, just because a magazine publishes a letter doesn't necessarily mean they endorse the contents. --Robert Merkel 02:29, 1 July 2006 (UTC)