Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Duplicate phrases in one cell
On Mon, 18 May 2009 12:19:29 +0100, "Peter T" <peter_t@discussions wrote:
I don't fully follow the objective but based solely on your examples, it looks like all you need to do is compare the left half with the right half. You could do that with a VBA (could be a UDF) or with a simple formula, eg =IF(LEFT(A1,LEN(A1)/2)=RIGHT(A1,LEN(A1)/2),LEFT(A1,LEN(A1)/2),A1) Very simple, and neat. --ron |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Duplicate phrases in one cell
On May 18, 1:45*pm, Ron Rosenfeld wrote:
On Mon, 18 May 2009 12:19:29 +0100, "Peter T" <peter_t@discussions wrote: I don't fully follow the objective but based solely on your examples, it looks like all you need to do is compare the left half with the right half. You could do that with a VBA (could be a UDF) or with a simple formula, eg =IF(LEFT(A1,LEN(A1)/2)=RIGHT(A1,LEN(A1)/2),LEFT(A1,LEN(A1)/2),A1) Very simple, and neat. --ron Excellent solutions! I am happy to report that these work perfectly for what I was wishing to do. I want to thank you guys very much for the ingenuity. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Duplicate phrases in one cell
"Ron Rosenfeld" wrote in message
=IF(LEFT(A1,LEN(A1)/2)=RIGHT(A1,LEN(A1)/2),LEFT(A1,LEN(A1)/2),A1) Very simple, and neat. --ron Why thank you Ron. Yours is very clever :-) Regards, Peter T |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Duplicate phrases in one cell
On Tue, 19 May 2009 11:34:01 +0100, "Peter T" <peter_t@discussions wrote:
Why thank you Ron. Yours is very clever :-) Regards, Peter T Mine uses Regular Expressions, and conceptually is doing the same thing as yours. But a formulaic expression is usually much faster. The only advantage to mine might be easy to change if the OP's requirements are a bit different than posted. --ron |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Duplicate phrases in one cell
"Ron Rosenfeld" wrote in message
Mine uses Regular Expressions, and conceptually is doing the same thing as yours. The only advantage to mine might be easy to change if the OP's requirements are a bit different than posted. Would you care to explain how (if left-half = right-half) re.Pattern = "^(.*)(\1)$" mc = re.Execute(theString) puts the left half in this mc(0).submatches(1) Regards, Peter T |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Duplicate phrases in one cell
On Tue, 19 May 2009 22:26:31 +0100, "Peter T" <peter_t@discussions wrote:
Would you care to explain how (if left-half = right-half) re.Pattern = "^(.*)(\1)$" mc = re.Execute(theString) puts the left half in this mc(0).submatches(1) Regards, Peter T I can try. Actually, its the right half that's in mc(0).submatches(1), but since the right and left halves are the same, it doesn't matter. The left half would be in mc(0).submatches(0). The pattern defines what is matched as follows: ------------------------ Paired phrases ^(.*)(\1)$ Assert position at the beginning of the string «^» Match the regular expression below and capture its match into backreference number 1 «(.*)» Match any single character that is not a line break character «.*» Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*» Match the regular expression below and capture its match into backreference number 2 «(\1)» Match the same text as most recently matched by capturing group number 1 «\1» Assert position at the end of the string (or before the line break at the end of the string, if any) «$» Created with RegexBuddy ---------------------------- Since the pattern includes the beginning and end of the line, it will only match if the left half = the right half. Then it's just a matter of returning one, or the other. See these references regarding Regular Expressions. They are from my bookmarks; hopefully some of them are still good! Regular Expressions http://www.regular-expressions.info/reference.html http://support.microsoft.com/default...02&Product=vbb http://msdn2.microsoft.com/en-us/library/6wzad2b2.aspx http://msdn2.microsoft.com/en-us/library/ms974619.aspx http://www.regex-guru.info/ --ron |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Duplicate phrases in one cell
Thanks for that Ron, it helps.
One of these days I'll try and get to grips with it, might need to get into a certain frame of mind first ! Regards, Peter T |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Duplicate phrases in one cell | Excel Programming | |||
Finding Duplicate Phrases in a File | Excel Worksheet Functions | |||
How to insert random phrases | Excel Worksheet Functions | |||
How to Replace Numbers with Phrases | Excel Discussion (Misc queries) | |||
How to Replace Numbers with Phrases | Excel Discussion (Misc queries) |