<div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif">Here is the link you need. <a href="https://developer.apple.com/reference/foundation/nsregularexpression#">https://developer.apple.com/reference/foundation/nsregularexpression#</a></div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">Zhaoxin</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jan 8, 2017 at 2:48 AM, Ethin Probst via swift-users <span dir="ltr">&lt;<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello all,<br>
This may be a very weird question. However, please bare with me while<br>
I explain this.<br>
I was speaking with a friend over Skype (we&#39;re both visually impaired,<br>
so use Windows for pretty much everything) and my friend asked me to<br>
develop a program that can take the numbers of vehicles (he&#39;s a GTA<br>
fan, :)) in KMH (kilometers per hour) and convert it into MPH (miles<br>
per hour). To do this, I chose Swift for this task, as I think it<br>
might be a good challenge for it. I am using RemObjects Elements to<br>
use Swift on .NET, Java, Cocoa, and Island to develop applications for<br>
these platforms. Island is a new platform in RemObjects Elements that<br>
allows developers to develop applications that use native API<br>
functions from the operating system. For instance, on Windows, I could<br>
directly (without any imports) use CreateWindowEx and all that to<br>
create a new window. Sadly this cannot be ported to Mac OS X, as Cocoa<br>
is reserved for that. :)<br>
Anyways, back to the topic I&#39;m trying to resolve. My friend gave me<br>
too files, specs_cars.txt and specs_motorcycles.txt. Both files are<br>
attached to this email (specs_cars.txt is nearly 45 KB in length and<br>
specs_motorcycles.txt is about 3.9 KB).<br>
So here&#39;s my question: I&#39;m on .NET, so yeah, but how would I go about<br>
using regular expressions to only search with lines that contain KMH<br>
(I&#39;ll show you how I want it to be done) and replace the numbers of<br>
KMH, along with the KMH itself, with MPH numbers followed by MPH? If<br>
you guys could help me solve this, I would be grateful, as I don&#39;t<br>
want to develop an entire parser for something like this, so regular<br>
expressions seem to be the way to go.<br>
<br>
Allow me to show you: In the specs_motorcycles.txt file, this:<br>
0-100kmh: 3.9s<br>
Should be replaced with:<br>
0-62.14kmh: 3.9s<br>
<br>
Now, this looks simple, but what about something like:<br>
Top speed: 218 kmh<br>
to be replaced with:<br>
Top speed: 135.5 kmh<br>
I hope you see my problem. I hope you can help me through this, and we<br>
can solve it together. :)<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
<br>
--<br>
Signed,<br>
Ethin D. Probst<br>
</font></span><br>______________________________<wbr>_________________<br>
swift-users mailing list<br>
<a href="mailto:swift-users@swift.org">swift-users@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-users</a><br>
<br></blockquote></div><br></div>