Objective-C/iPhone - Reading a word from text file. Looping through if word exists - iphone

I'd like to create a list of explicit words in a text file. I then want to be able to read and loop through this file on the iPhone. What would be the best way to do this?
e.g.,
explicit.txt
hello
world
freddy
jason
foo
bar
Then just before I save the information I'd like to popup a message to notify the user that a particular word is explicit.

If you have too many words, it's better to use a database.
But if they're just some words you can try this idea:
Store the words in explicit.txt file in the following format:
|hello|world|freddy|jason|foo|bar|
Then load the whole text and search for the substring |word|.
If you find it then the given word is explicit:
NSString *explicitWords = [NSString stringWithContentsOfFile:#"explicit.txt"];
if ([explicitWords rangeOfString:#"|word|"].location != NSNotFound) {
// the given word is explicit.
}

You probably want to use a property list, instead of a text file.
Check out the programming guide for lots of info.
http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/PropertyLists/Introduction/Introduction.html%23//apple_ref/doc/uid/10000048i

Related

VSCode multiline search of two words?

I saw a SO post that says you can search using regex or an actual literal text on it to search multiline texts. But what if you want to (quickly) search two or three of words within a specified lines of text content?
For example, what if you want to search for multiline text area that contains "ruby" and "regex" (assuming you want to know where you took a note on your txt (or markdown or rich text format) file. you may want to search for "how to use regex in ruby" or "the ruby regex tutorial", right? )
Now you can use a simple (but redundant) regex like ruby(.*\n)+regex|regex(.*\n)+ruby. But to me it doesn't look beautiful. For three or more words, this kind of regex workaround increases its redundancy exponentially also, not good.
So is there a smarter way to do this? Thanks.

How to convert certain words to another word

So I have a field that is a short form for a certain word. For example: EXT is Extension
When the word is displayed in my report, I need it to show Extension. There are a list of words that I need converted. So how do I convert a certain list of words to another word but if the word is not on my list in the formula, then keep it the same as it is.
If EXT then Extension
If APP then Appointment
Otherwise, keep the field as it is.
Define a formula named AnotherWord for example. It contains the following code:
IF {Word} = "EXT" Then
"Extension"
Else IF {Word} = "APP" Then
"Appointment"
ELSE
{Word}
You can add additional options as you see fit.

MS Access Convert from Unicode when Reading from Text File

So, I have an Access database where I import data from a text file. The file is semi-colon delimited. Occasionally (and will become more frequent) I receive a file from one of our affiliates from Russia. The file has unicode (I think) characters like "Ìèðîøíèêîâ" instead of "Мирошников". Ultimately, I'd like to translate those into English upon import, but for now, I'll accept the Russian characters.
How should I go about doing this? Currently, I'm reading each line of the file, using the SPLIT function to separate each field by the ";" separator into an array, and sticking each array element into a table. Would changing the system Keyboard Layout to Russian prior to this work, or is it more complicated than that.
Does any of this make sense, or should I just bag it and go grab a beer (or some Vodka)?
Thanks!
You should be able to create an "Import Specification" that will tell Access how to convert the character data. Follow the procedure here...
Importing a text with separators using VBA
...and choose the appropriate character set from the "Code Page" combo box.
If you need to perform the imports from VBA code then you can save the specification (using the "Save As..." button) and then re-use that specification in a DoCmd.TransferText statement.

Remove characters from string iOS

I have an XML which I am using to parse news. News have a description. I'm using NSString to show that description in UILabel.
But, the description comes like this:
Bad news for Windows’ the researches show that Windows’ for years....
And it is being showed with those unwanted characters in UILabel. The numbers are changing in every string. They are not the sames.
I want to remove the characters that begins with &# and the numbers that follow. How can I do that? Which string encoding format should I use?
Thanks a lot.
EDIT: I don't have just one string. If I remove &#8217 from this one, there might be &#7610 in another one. It won't be removed.
I can remove &# characters and numbers too. But when I do that, In a string like that "In 1980, Jobs told us to&#2540 do something" the output will be "In , Jobs told us to do something" 1980 will be gone too, but I don't want that. That's a problem either.
These are ASCAII symbols so you need to use utf-8 string.check this link
so use this line of code
NSString *resultString = [NSString stringWithUTF8String:myAsciiString];

Way to preserve formatting for lists when copy / pasting from table cell?

My Word interop application needs to get content out of a cell of a table in a word document. The problem is, that the formatting for some items seems broken. For example the last item of a list does not have the list style applyied. Headings are only normal text etc.
The same happens if you create a table, create a list in the table and try to copy / paste the list to somewhere else.
Has anyone else had this problem and maybe found a solution? Is there any way to trick word into giving the correct formatting?
Thanks in advance
Example code
Range range = cell.range;
range.MoveEnd(WdUnits.wdCharacter, -1);
...
range.FormattedText.copy()
The range includes the end-of-cell marker which should not be exported. I just noticed, when not altering the range, list are correctly formatted but the whole cell is exported as a table, which is bad because i want to import the content into another document (where this would nest tables infinitly)
Word2010 v14.06.6112.5000