ANTICHAT — форум по информационной безопасности, OSINT и технологиям
ANTICHAT — русскоязычное сообщество по безопасности, OSINT и программированию.
Форум ранее работал на доменах antichat.ru, antichat.com и antichat.club,
и теперь снова доступен на новом адресе —
forum.antichat.xyz.
Форум восстановлен и продолжает развитие: доступны архивные темы, добавляются новые обсуждения и материалы.
⚠️ Старые аккаунты восстановить невозможно — необходимо зарегистрироваться заново.

23.06.2009, 00:02
|
|
Участник форума
Регистрация: 03.02.2009
Сообщений: 104
Провел на форуме: 270228
Репутация:
70
|
|
Сообщение от rudvil
Воть, обновленная версия реплейсера переписал все с нуля - повышена скорость работы, меньше строчек кода.
Replace (Исходник, НайтиЧто, ЗаменитьЧем);
Пример:
Код:
string hello = "Hello World!";
Replace(hello, "o", "_");
cout << hello << endl;
выведет: Hell_ W_rld!
и ещё
string hello = "Hello Worlld!";
Replace(hello, "ll", "[*]");
cout << hello << endl;
выведет: He[*]o Wor[*]d!
Исходник:
Код:
#include <iostream>
#include <string>
using namespace std;
void Replace (string& source, string find_what, string replace_with) {
if (source == "" || find_what == "") {
return;
}
if (source == find_what) {
source = replace_with;
return;
}
unsigned int findwhat_index = 0,
start_index = 0,
find_length = find_what.length(),
flag = 0;
for (unsigned int i = 0; i < source.length(); i++ ) {
switch (flag) {
case 0:
if (source.at(i) == find_what.at(0) && find_length == 1) {
source = source.replace(i, 1, replace_with);
}
else if (source.at(i) == find_what.at(0)) {
start_index = i;
findwhat_index++;
flag = 1;
}
break;
case 1:
if (source.at(i) == find_what.at(findwhat_index) && findwhat_index < (find_length - 1)) {
findwhat_index++;
}
else if (source.at(i) == find_what.at(findwhat_index) && findwhat_index == (find_length - 1)) {
source = source.replace(start_index, find_length, replace_with);
findwhat_index = 0;
start_index = 0;
flag = 0;
}
else {
findwhat_index = 0;
start_index = 0;
flag = 0;
}
break;
}
}
}
Не считаю хорошей идеей использовать в этой функции тип string ((..
ИМХО лучше реализовать с char;
|
|
|

23.06.2009, 00:07
|
|
Участник форума
Регистрация: 25.08.2008
Сообщений: 187
Провел на форуме: 2066562
Репутация:
86
|
|
Сообщение от [n]-c0der
Не считаю хорошей идеей использовать в этой функции тип string ((..
ИМХО лучше реализовать с char;
Сообщение от rudvil
Написал вот такой реплейсер т.к. встроенный в C++ для меня не неудобен.
писал специально для <string> 
|
|
|

17.10.2009, 01:11
|
|
Познающий
Регистрация: 16.10.2009
Сообщений: 40
Провел на форуме: 152013
Репутация:
14
|
|
M3U Copying
Простенькая консольная программа для копирования музыки из M3U списка в заданную папку, полезна при необходимости выделения музыки из списка для дальнейшей обработки
Язык C#
Код:
using System; using System.Collections.Generic; using System.Text; using System.IO; namespace M3UCopyer { class Program { static void Main(string[] args) { string filePath; //Path to M3U File string collectionPath; //Path to end folder List<string> fNamesCol = new List<string>(); //File names int i = 0; //i string s = ""; //Temporary /*****************************************************************COPYRIGHT*************************************************************/ Console.WriteLine(); Console.ForegroundColor = ConsoleColor.Green; Console.Write("======================================================"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("-------"); System.Threading.Thread.Sleep(250); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(">>>>>>>>>>>>>"); System.Threading.Thread.Sleep(250); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(); Console.WriteLine("|-----------------------COPYRIGHT (C) ICHECHEN-------------------------|"); System.Threading.Thread.Sleep(250); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.Red; Console.Write("<<<<<<<<<<<<<"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("-------"); System.Threading.Thread.Sleep(250); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("======================================================"); System.Threading.Thread.Sleep(250); Console.WriteLine(); /***************************************************************************************************************************************/ Console.WriteLine(); if (args.Length < 1) { Console.ForegroundColor = ConsoleColor.DarkYellow; Console.WriteLine("Please enter M3U file address: "); Console.ForegroundColor = ConsoleColor.Yellow; filePath = Console.ReadLine(); Console.ForegroundColor = ConsoleColor.DarkYellow; Console.WriteLine("Please enter path to you collection: "); collectionPath = Console.ReadLine(); try { StreamReader sr = new StreamReader(filePath, System.Text.Encoding.GetEncoding(1251)); /*******************************Extracting to fNameCol*******************************/ sr.ReadLine(); while (!sr.EndOfStream) { if (i == 1) { s = sr.ReadLine(); if (s.Substring(1, 1) != ":") { s = filePath.Substring(0, 3) + s; } fNamesCol.Add(s); i = 0; } else { sr.ReadLine(); i++; } } sr.Close();// /****************************************FILE COPY************************************/ if (fNamesCol.Count > 0) { FileInfo f; if (collectionPath.Substring(collectionPath.Length - 1, 1) != Convert.ToString('\\')) { collectionPath = collectionPath + Convert.ToString('\\'); } foreach (string fp in fNamesCol) { f = new FileInfo(fp); Console.WriteLine(fp); File.Copy(f.FullName, collectionPath + f.Name, true); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("OK!"); Console.ForegroundColor = ConsoleColor.DarkYellow; } Console.ReadLine(); } } catch { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Bad M3U filename!"); System.Threading.Thread.Sleep(1000); } } } } }
Скачать .exe => http://depositfiles.com/files/l1v0cmmwb
|
|
|

17.10.2009, 01:36
|
|
Познающий
Регистрация: 16.10.2009
Сообщений: 40
Провел на форуме: 152013
Репутация:
14
|
|
ISDB
Последний раз редактировалось Егорыч+++; 10.02.2010 в 22:40..
|
|
|
|
 |
|
|
Здесь присутствуют: 1 (пользователей: 0 , гостей: 1)
|
|
|
|