Xcode finding multiple lines using regular expression - objective-c

I have the following lines in my code at many places. I want to find all of them at once and replace each of such block with new comment. However i am able search single line at a time. But i am not getting how to include new line in my regular expression to search please help.
// Block Solver
// We develop a block solver that includes the joint limit.
// when the mass has poor distribution (leading to large torques about..
//
Thanks in advance

Search for:
^(?://.*\n?)+
and replace all with nothing.
This will find all lines that start with //.

Related

Maya crashes when duplicate special

I try to make instance copies of my character using Duplicate Special. But unfortunately it crashes every time I try.
For this I select my character's group "rig_group", then go to Edit → Duplicate Special ⊡
And I want to use these settings:
And it crashes Maya when I hit "Apply" or "Duplicate Special".
Note that it works on this character on a fresh file.
Test file - M01_WalkNeutral.0080.mb
Remember that duplicate special doesn't work properly on rig's. You can use duplicate special for polygons, curves or etc.
Ps. If you wanted to duplicate special a high-poly mesh I would say that to reduce the vertex then run that but about rig_group I'm not sure.
I hope to help that to you.

Dollar and exclamation mark (bang) symbols in VTL

I've recently encountered these two variables in some Velocity code:
$!variable1
!$variable2
I was surprised by the similarity of these so I became suspicious about the correctness of the code and become interested in finding the difference between two.
Is it possible that velocity allows any order of these two symbols or do they have different purpose? Do you know the answer?
#Jr. Here is the guide I followed when doing VM R&D: http://velocity.apache.org/engine/1.7/user-guide.html
Velocity uses the !$ and $! annotations for different things. If you use !$ it will basically be the same as a normal "!" operator, but the $! is used as a basic check to see if the variable is blank and if so it prints it out as an empty string. If your variable is empty or null and you don't use the $! annotation it will print the actual variable name as a string.
I googled and stackoverflowed a lot before I finally found the answer at people.apache.org.
According to that:
It is very easy to confuse the quiet reference notation with the
boolean not-Operator. Using the not-Operator, you use !${foo}, while
the quiet reference notation is $!{foo}. And yes, you will end up
sometimes with !$!{foo}...
Easy after all, shame it didn't struck me immediately. Hope this helps someone.

IEnumString searching substrings - possible?

I've implemented auto completion to a combobox like this article shows. Is it possible to make it search for substrings instead of just the beginning of the words?
http://www.codeproject.com/Articles/2371/IAutoComplete-and-custom-IEnumString-implementatio
I haven't found any way to customize how IEnumString/IAutoComplete compares the strings. Is it possible?
The built in search options help a bit but it is complete chaos. To find instring matches you need to set flag AcoWordFilter. But this will prevent from numbers being matched!! However, there is a trick to get the numbers to match: preced with a double-quote as in "3 to find a string containing or starting with "3". Some more chaos? In the AcoWordFilter you also need to prefix other characters not considered part of a "word", eg. you need to prefix parentheses with a " but then you will not find parentheses at the first position!
So the solution is either to create your own implementation of IAutoComplete or offer the user to switch between the modes (a bit awkward).
I dont think that the MS engineers are especially proud of such chaos. How about one more option: AcoSearchAnwhere?
After retrieving the Edit control's IAutoComplete interface, query it for an IAutoComplete2 interface. Calling its SetOptions member you can disable prefix filtering by specifying the ACO_NOPREFIXFILTERING AUTOCOMPLETEOPTIONS.
This is available on Windows Vista and later. If you need a solution that works with pre-Vista versions, you'll have to write your own.

How to Keep Velocity Ouput to a Single Line while Spanning Multiple Lines in vm File

I'm using a Velocity template to generate an e-mail. Within that e-mail, I want to create a mailto link that will look like this:
Link
I have this chunk of code that properly creates that link:
Link
That code works, but it's nearly impossible to read. I want to put some line breaks in there so that I'd have something more like this:
<a href="mailto:
#foreach(${person} in ${people})
${person.email}
#if($foreach.hasNext)
,
#end
#end
?subject=My%20Subject%20Line">Link</a>
I find that to be much easier to read, but Velocity will include all the whitespace into the output and causes the link that it produces to break.
Is there any way to format the code the way I want and tell Velocity to ignore all the whitespace throughout that segment?
Thanks!
A first option is to use comments:
<a href="mailto:#*
*##foreach(${person} in ${people})#*
*#${person.email}#*
*##if($foreach.hasNext)#*
*#,#*
*##end#*
*##end#*
*#?subject=My%20Subject%20Line">Link</a>
Another option is to add a pre-processing that will remove all indenting spaces and carriage returns.
Yet another is to do it as a post-processing.
The way to add this pre- or post- processing is dependent on the context in which you are using Velocity.

Regexp in iOS to find comments

I am trying to find and process 'java-style' comments within a string in objective-C.
I have a few regex snippets which almost work but I am stuck on one hurdle: different options seem to make the different styles work.
For example, I am using this to match:
NSArray* matches = [[NSRegularExpression regularExpressionWithPattern:expression options:NSRegularExpressionAnchorsMatchLines error:nil] matchesInString:string options:0 range:searchRange];
The options here allow me successfully find and process single line comments (//) but not multiline (/* */), if I change the option to NSRegularExpressionDotMatchesLineSeparators then I can make multiline work fine but I can't find the 'end' of a single line comment.
I suppose really I need dot-matches-line-separators but I need a better way of finding the end of a single line comment?
The regexp I have so far are:
#"/\\*.*?\\*/"
#"//.*$"
it's clear to see if dot matches a line separator then the second one (single line) never 'finishes' but how do I fix this? I found some suggestions for single line that were more like:
#"(\/\/[^"\n\r]*(?:"[^"\n\r]*"[^"\n\r]*)*[\r\n])"
But that doesn't' seem to work at all!
Thanks in advance for any pointers.
So it turns out the example I had was pretty close its just for some reason I had some additional backslashes in there that weren't needed, it now reads:
#"(//[^\"\n\r]*(?:\"[^\"\n\r]*\"[^\"\n\r]*)*[\r\n])"
(that is, in the code for Objective-C). And to clarify my own point, I am using DotMatchesLineSeparator and this is working now exactly as I'd expect.