#11 2008-04-16 18:09

eR@SeR
Senior Member
From: Земун, Србија
Registered: 2008-01-23
Posts: 353

Re: Swap parts and space out words

Who would ever thought that I will resolve mine problem (question) lol:lol::lol:

Thank you for giving me the pattern... I experimented a while with moving, editing your RegEx and finally I managed.

Here it is: Expression: "([a-z+])([A-Z])"
               Replace: "$1 $2"

Edit: case-sensitive is checked (forgot to mention)

Yeeeah I'm "genius" big_smile

Last edited by eR@SeR (2008-04-16 18:12)


TRUTH, FREEDOM, JUSTICE and FATHERLAND are the highest morale values which human is born, lives and dies for!

Offline

#12 2008-04-16 19:08

krtek
Senior Member
From: Łódź (Poland)
Registered: 2008-02-21
Posts: 262

Re: Swap parts and space out words

Wow, I was sure, that you've misstyped the expression, but I've checked and it works...
Let's figure it out.

+ means "repeated at least once" (BTW: * means "repeated 0 or more times")
[a-z]+ means "any lowercase letter repeated at least once" (eg. a, bk, cat and so on)
Putting + inside [], like you've done [a-z+] means: "any of lowercase letter or + sign" - only one sign - (eg. a, +, b, h, and so on).

And trying that expression:
Expression: ([a-z])([A-Z])
Replace: $1 $2
which also works fine in your case gives us an answer to the problem.

The truth is that we think that in [a-z+] regex is looking for one or more letters, and regex does what it should do: looking for one (and only one) lowercase letter or + sign. So it is a bit of mistake.
Try to see what will happen when you feed both expressions with filename like this "WideLower+Case".
Yours will produce "Wide Lower+ Case"
Mine will produce "Wide Lower+Case"

So the regex finds a lowercase letter followed by the Uppercase letter and inserts a space between them.
And you've definetely improved the regex by swapping parts of expression (no need for second rule what I like most big_smile ).
Congratulations!!!
But we have to go one step further and get rid of the + sign, as it is unnecessary and may produce errors.

And now if you get on the idea that what you really need is insiding a space between any sign and UpperCase letter you need that regex (Replace part will be the same):
Expression: ([^A-Z])([A-Z])
[^] - is a negated class, so [^A-Z] means "anything that is not an UpperCase letter".

This will produce "Wide Upper- Case" from "WideUpper-Case"; "Wide Lower& Case" from "WideLower&Case" and so on.
But it won't split UpperCase letters, so it will produce "Wide UPPer Case" from "WideUPPerCase".

Cheers!
And good luck on the way to RegEx's big_smile


Ps. WOW, I was just promoted to Senior Member lol:lol::lol:

Last edited by krtek (2008-04-16 19:19)


Regular Expressions are not as hard to understand as you may think. Check ReNamer's manual or nice Regular Expressions tutorial for more info and start to use full power of applications that use them (like ReNamer, Mp3Tag and so on).

Offline

#13 2008-04-16 20:39

eR@SeR
Senior Member
From: Земун, Србија
Registered: 2008-01-23
Posts: 353

Re: Swap parts and space out words

Thanks for approval big_smile

I tested several combinations (including similar to yours for example Tute-WealthLab-English) and it works.

Why shouldn't? roll Edit: Oh yes, that sign + will make problems (if is in the filename). I tried and I get it the same issue hmm

In fact, like you said, your thinking of one step further is not bad, contrary, it is excellent smile

But I just wanted to separate low from upper case and that's it. Other characters, for me, doesn't matter. Edit: Erased (it was nonsense tongue)
Like you said this is the right solution:
([a-z])([A-Z]) ----> when you look at this RegEx looks really, really simple smile
$1 $2 -------------> when you look at this RegEx looks really, really simple smile
case-sensitive is checked

To be honest I was thinking logicaly what have should be done and for a minute I figure out, it wasn't too hard tongue

Just give me a pattern and I'll make the appropriate changes big_smile. For now I can do that. I don't have experience in RegEx "language". Thank you for making things more clear now smile.

And good luck on the way to RegEx's

Thanks! roll

Ps. WOW, I was just promoted to Senior Member

Congrats but I'm right behind you, beware cool

Last edited by eR@SeR (2008-04-16 20:58)


TRUTH, FREEDOM, JUSTICE and FATHERLAND are the highest morale values which human is born, lives and dies for!

Offline

#14 2008-04-16 21:16

eR@SeR
Senior Member
From: Земун, Србија
Registered: 2008-01-23
Posts: 353

Re: Swap parts and space out words

You learn on mistakes. That is the real truth. big_smile

In first case, you "wrong". Then I make some combinations from yours RegEx without removing + character which showed good but not excellent because of this possible situation WideLower+Case. Then you finally get into the core of possible problems made by mine modification and managed that really, simple RegEx.

We "lost", but finally get the real and best solution. Applause for us big_smile

P.S. This RegEx (mine opinion) are really close with programming which is mine miserable side sad
Sorry for misunderstandings krtek roll. There was it from mine side sad


TRUTH, FREEDOM, JUSTICE and FATHERLAND are the highest morale values which human is born, lives and dies for!

Offline

#15 2008-04-16 22:00

krtek
Senior Member
From: Łódź (Poland)
Registered: 2008-02-21
Posts: 262

Re: Swap parts and space out words

I like to wander around. You need to be lost if you want to feel that great feeling of finding the right way.
And teamwork makes finding the way even more interesting.

Regexes are far far simpler then any programming language and code. And they are extremally elegant.
They are more like patterns. It is writing an abstract sentence. You don't use words (although you can) but abstract symbols which can be replaced with real words. And when you write this sentence you can move its parts as you would do it with scissors and glue if they were written on a paper.

It takes about two-three days to walk through the tutorial on http://www.regular-expressions.info/ but it is worth to do that.

Thanks for losting together tongue


Regular Expressions are not as hard to understand as you may think. Check ReNamer's manual or nice Regular Expressions tutorial for more info and start to use full power of applications that use them (like ReNamer, Mp3Tag and so on).

Offline

#16 2008-04-16 22:27

eR@SeR
Senior Member
From: Земун, Србија
Registered: 2008-01-23
Posts: 353

Re: Swap parts and space out words

I like to wander around. You need to be lost if you want to feel that great feeling of finding the right way.
And teamwork makes finding the way even more interesting.

Totally agree big_smile. I felt that feeling (like I discovered an electricity-power) cool.
Without teamwork there is no victory smile.

And when you write this sentence you can move its parts as you would do it with scissors and glue if they were written on a paper.

Something like that smile. Yes, I understood that in the first place, but only that symbols and making a patterns are making me "troubles" to apprehend...

It takes about two-three days to walk through the tutorial on http://www.regular-expressions.info/ but it is worth to do that.

I don't know will I learn in two-three days roll. Problems are "trigger force" to make you think about resoving it. Persistence, endurance, work habits... are major principles. If you have them, then you don't know what the word problem is neutral:|:|

Last edited by eR@SeR (2008-04-16 22:29)


TRUTH, FREEDOM, JUSTICE and FATHERLAND are the highest morale values which human is born, lives and dies for!

Offline

#17 2008-04-18 14:29

eR@SeR
Senior Member
From: Земун, Србија
Registered: 2008-01-23
Posts: 353

Re: Swap parts and space out words

Ooohh krtek sorry for making you all these troubles to you and me off course sad
It was mine mistake for unexploring the rest of topics roll

There were already answer to mine question at this topic http://www.den4b.com/forum/viewtopic.php?id=426

And Denis have made a script also. http://www.den4b.com/forum/viewtopic.php?id=14

But one is sure. I learnt something more and probably you does, also big_smile

Last edited by eR@SeR (2008-04-18 14:30)


TRUTH, FREEDOM, JUSTICE and FATHERLAND are the highest morale values which human is born, lives and dies for!

Offline

#18 2008-04-20 12:04

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,378

Re: Swap parts and space out words

It is good to see both of you racing for the most active/supportive user, I really appreciate it! big_smile

Offline

Board footer

Powered by FluxBB