RE: Converting a string

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[snip]
	IMHO, you do are in position to tell the designers how the
fields 
should be named, after all they won't give any use to them, it's you (or

the developer in turn) who will deal with them.  Besides, using 
underscores (or any other space-replacement) anyone knows beforehand 
what the text displayed will be, and any special combination of 
lower/upper-case letters it's preserved.

	Anyway, right now it seems this is something we can't depend on,
so 
let's refine the expression a little.  Oh, and I was refering to the 
same "problem" with fields such as "MyURL".

	I've changed a little the pattern, now it would say "ignore the
initial 
lower-case letters and spaces (if any of those) and add a space before 
any upper-case wich is not preceeded by an upper-case, and also those 
upper-case followed by a lower-case", so it now would look like
   $rex_initial = '/^[a-z]*\s*/X';
   $rex_upper   = '/(?<![A-Z])(?=[A-Z])|(?=[A-Z][^A-Z])/X';
   $text        = preg_replace($rex_initial, '',
                               preg_replace($rex_upper, ' ', $name) );
	I think that solves the problem with the previous one.  But I'd
also 
like to point out that most of us (you included, if I understood right) 
seem to agree that this shouldn't be the first option, but something 
simplier --this is more like a patch than a feature ;)

	Good luck with the designers :)
[/snip]

You're correct, this shouldn't be the first option. 

Right now the designers are not under my control as they are outsourced
and working with a set of specs created by someone who is/was no longer
here when I got here (for good reason and this kind of thing is but one
of those reasons). I am working to get designers on staff (and they will
work for me), but until that point I have to work with what I have as
the business is approaching launch and we really don't have time to go
back and rework existing forms, etc.

So, being the good systems guy that I am, I try to get it where everyone
can work together with as little hassle as possible. We had worked this
same problem on this same list about a year ago, so I knew that there
was an answer, I just couldn't find it. Thanks to your truly elegant
solution I have made developer world much happier this afternoon.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux