تلاش کریں اور بدلیں

استعمال کا طریقہ 3 مراحل
  1. اپنا عبارت چسپاں کریں۔
  2. کیا تلاش کریں کرنا ہے اور کس سے اس سے بدلیں کرنا ہے لکھیں، اور موڈ چنیں۔
  3. ضرورت ہو تو بڑے چھوٹے حروف کا فرق رکھیں یا صرف مکمل الفاظ پر نشان لگائیں، پھر بدلیں اور کاپی کریں دبائیں۔
لفظی عبارت، یا regex موڈ میں کوئی نمونہ۔
regex موڈ میں کیپچر گروپس کے لیے $1، $2 استعمال کریں۔
نتیجہ

یہ ٹول کیسے کام کرتا ہے

دونوں طریقے آخرکار ایک regular expression بن جاتے ہیں۔ لفظی طریقے میں آپ کا لکھا ہوا ہر حرف پہلے محفوظ کر دیا جاتا ہے، اس لیے نقطہ صرف نقطے سے میل کھاتا ہے اور کسی اور چیز سے نہیں، اور بدلنے والی عبارت بھی محفوظ کی جاتی ہے — ڈالر کا نشان ڈالر ہی رہتا ہے، گروہ کے حوالے کے طور پر نہیں پڑھا جاتا۔ regex طریقے میں آپ کا نمونہ جوں کا توں مرتب ہوتا ہے، جو آپ کو گروہ، متبادل اور حروف کے طبقے دیتا ہے، اور کچھ غلط لکھنے کا موقع بھی۔

جب تک آپ خانہ نشان زد نہ کریں، مطابقت چھوٹے بڑے حروف کا فرق نہیں دیکھتی۔ دائرہ طے کرتا ہے کہ ہر موقع بدلا جائے یا صرف پہلا۔ پورے لفظ کا اختیار آپ کی عبارت کو لفظ کی حدوں میں لپیٹ دیتا ہے اور صرف لفظی طریقے پر لاگو ہوتا ہے، کیونکہ regex طریقے میں آپ خود حدیں لکھ سکتے ہیں۔ اگر نمونہ مرتب نہ ہو سکے تو عام ناکامی کے بجائے regular expression انجن کی اپنی خرابی دکھائی جاتی ہے۔

نتیجہ پڑھنا اور پھندوں سے بچنا

  • دو عدد بتائے جاتے ہیں، اور وہ جان بوجھ کر مختلف ہوتے ہیں: پہلا یہ کہ عبارت ان پُٹ میں کہیں بھی کتنی بار آتی ہے، دوسرا یہ کہ درحقیقت کتنی بار بدلی گئی۔ چھ مطابقتوں میں سے صرف پہلی بدلنے پر چھ اور ایک بتایا جاتا ہے۔
  • پورا لفظ خالی جگہ نہیں، لفظ کی حدیں دیکھتا ہے: حد کسی حرف یا ہندسے اور کسی دوسری چیز کے درمیان ہوتی ہے، اس لیے خط والے اور واوین والے الفاظ اوقاف پر بٹ جاتے ہیں، اور نیچے کی لکیر لفظ کا حصہ شمار ہوتی ہے۔
  • لفظی طریقے میں ڈالر کے نشان محفوظ ہیں: قیمتیں اور متغیر کے نام بالکل ویسے ہی بدلے جاتے ہیں جیسے لکھے گئے۔ regex طریقے میں وہی عبارت گروہ کا حوالہ بن جاتی ہے، اس لیے اسے سوچ کر استعمال کریں یا محفوظ کر لیں۔
  • اصل عبارت کبھی تبدیل نہیں ہوتی: ان پُٹ اپنی جگہ رہتا ہے اور نتیجہ الگ دکھایا جاتا ہے، اس لیے کسی حد سے زیادہ پھیلے ہوئے نمونے کی قیمت صرف ایک اور کوشش ہے۔

Case-insensitive by default

Worth knowing before your first run, because it is the setting most likely to produce a surprise.

Searching for cat matches Cat and CAT as well, and replaces all of them with exactly what you typed. So replacing cat with dog turns a sentence-opening Cat into a lowercase dog.

The [msm_tool slug="find-and-replace"] has a case-sensitive option, and for anything where capitalisation carries meaning — names, code identifiers, sentence starts — it is the one you want.

Whole words, and why partial matches bite

Without whole-word matching, a search for cat also matches the middle of concatenate, category and indicated. Replacing it produces condogenate, which is the classic demonstration and happens constantly in practice.

The rule: if you are replacing a word, match whole words. If you are replacing a fragment — a URL, a prefix, a file extension — you cannot, and you should read the preview more carefully.

Order matters when you make several replacements

Replacements are applied in sequence, and each one runs on the result of the last. That creates a specific trap:

Replace A with B, then B with C, and everything that was originally A is now C. You wanted two separate substitutions and got a chain.

The fix is to route through a placeholder that appears nowhere in the text — replace A with a unique marker, then B with C, then the marker with B. Awkward, and reliable.

The same applies to swapping two values. There is no way to do it in two steps without the intermediate collision.

Check the count before you commit

The number of replacements is the single most useful thing to look at. If you expected three and it reports forty-seven, stop — something is matching that you did not intend, and it is almost always a partial match or a case difference.

A count of zero is equally informative. It usually means a typo in the search term, a trailing space, or a character that looks like the one you typed and is not — a curly quote where you typed a straight one, or a non-breaking space where you typed a normal one.

Quotes and dashes that look identical

Text from a word processor or a website carries typographic characters: curly quotes, en dashes, ellipsis characters. They look like their plain equivalents and are different code points.

Searching for "quoted" with straight quotes will not find “quoted” with curly ones. This is behind a large share of the searches that mysteriously find nothing, and the fix is to copy the search term out of the text itself rather than typing it.

Where this is the right tool

  • Changing a name, a term or a URL consistently through a document.
  • Cleaning up a placeholder left in a template.
  • Converting a delimiter — commas to tabs, semicolons to newlines.
  • Stripping a repeated prefix or suffix from a list of lines.

Where it is not

Anything requiring judgement about context. Replacing a word only when it appears as a noun, or only outside quotation marks, or only in some sections, is not a find-and-replace job — and attempting it with a clever search term is how documents get quietly corrupted.

Keep the original. Everything happens in your browser, so nothing is uploaded, but nothing is undoable either.

اکثر پوچھے گئے سوالات

خاص طور پر تلاش کریں اور بدلیں کے بارے میں۔ اس زمرے سے متعلق عمومی سوالات کے جواب زمرے کے صفحے پر موجود ہیں۔

جی ہاں، regex طریقے میں: نمونے کا کوئی حصہ قوسین میں رکھیں اور ڈالر کے نشان اور اس کے نمبر سے اس کا حوالہ دیں۔ لفظی طریقہ ڈالر کے نشان کو عبارت ہی سمجھتا ہے۔
یہ صرف لفظی تلاش پر لاگو ہوتا ہے۔ اس کے بجائے حد کے نشانات اپنے نمونے میں خود شامل کریں، جس سے انہیں صرف ایک طرف رکھنے کی سہولت بھی ملتی ہے۔
دائرہ پہلے موقع پر لگا ہوا تھا۔ گنتی آپ کو بتاتی ہے کہ کتنی موجود ہیں تاکہ آپ فیصلہ کر سکیں کہ اسے سب پر چلانا ہے یا نہیں۔
کچھ نہیں بدلا جاتا اور انجن کا پیغام دکھایا جاتا ہے، جو عموماً مسئلے کی جگہ بتا دیتا ہے — کوئی بند نہ کی گئی قوس یا کوئی بھٹکا ہوا مقدار نشان۔
نہیں۔ ان پُٹ ویسے کا ویسا رہتا ہے اور نتیجہ الگ ظاہر ہوتا ہے، اس لیے آپ نمونہ درست کر کے اسی نقطۂ آغاز سے دوبارہ چلا سکتے ہیں۔

نئے ٹولز، خصوصیات اور کارکردگی بڑھانے کے مشوروں کی اطلاع پانے کے لیے سبسکرائب کریں۔