regex - Use JavaScript String replace function to remove a function in a string -


मेरे पास यह स्ट्रिंग है

  str = 'function1 (function2 (function3 (param1, param2) , परम 3), परफॉर्मेंस 2)) '  

और मैं फ़ंक्शन 3 को निकालना चाहूंगा और इसे param1 द्वारा प्रतिस्थापित करना चाहूँगा मैं फ़ंक्शन 3 के आसपास और अधिक फ़ंक्शंस कर सकता हूं लेकिन मुझे इस फ़ंक्शन का नाम पता है और यह परिवर्तित नहीं होता है।

अपेक्षित परिणाम

  function1 (function2 (param1, Paramfunction2))   

जावास्क्रिप्ट में मैं

  str.replace (/ function3 [(] (। *),। *,। * []] /, '$ 1')   

और मुझे हमेशा मिलते हैं, मैं केवल फ़ंक्शन 3 को अलग नहीं कर सकता

  function1 (function2 (param1, param2    

आपका सवाल जावास्क्रिप्ट-विशिष्ट नहीं है। आपको लालची के बजाय गैर-लालची परिमाण का उपयोग करना चाहिए ।

  str.replace (/ function3 [(] (। *?), *।,। *? []] /, '$ 1')   

प्रश्न चिह्नों पर ध्यान दें।

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -